I need to sort my output because I want to animate my output in Leaflet. I realize that I could sort the resulting GeoJSON in my JavaScript code but that is less efficient.

When I Googled it I got to the GeoServer 2.12.x documentation that suggested I use an addition to my query SortBy=&. So here is what my URL looks like:


So that didn't work, no error so I assume that GeoServer ignored the SortBy.

Any ideas?

EDIT: OK, I'm an idiot! It was working all along, I just didn't recognize it. I was judging whether it sorted correctly by the display order of the markers in Leaflet. As user30184 pointed out, without including the SortBy field(s) in the output it's hard to ascertain if the sort worked correctly. I did some experimentation with adding +Desc to the sort field to get it to sort backwards and did some key comparisons and see that all's well. Adding credit because user30184 helped with correct syntax, plus I learned a bit from the answer.


First thing, the version in the query means to version of the WFS standard, not the version of GeoServer as I suppose that you mean with your "2.11.2"

Here are some examples of syntax that seems to work. Firs examples are sorting by a selected feature so it is possible to check if the result is right.



These examples use attribute "PERSONS" for "sortby" which makes it hard to say if the result is right or not because "PERSONS" is not selected into output but that is similar case than the one you use in your question.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.