Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort lists of items sensibly before returning them (?) #71

Open
tripu opened this issue Dec 17, 2016 · 9 comments
Open

Sort lists of items sensibly before returning them (?) #71

tripu opened this issue Dec 17, 2016 · 9 comments

Comments

@tripu
Copy link
Member

tripu commented Dec 17, 2016

How difficult would it be on the API backend [or, would it make sense] to sort lists of items by some relevant field? Right now, some lists are sorted according to some kind of useful order; others look shuffled.

Specifically:

There may be others (I'll add here if I find them).

Most clients I can think of will have to sort those lists themselves anyway. (That's the case with Apiary and Unitas, at least.) Doesn't it make more sense to sort them on the server before returning them?

@tripu
Copy link
Member Author

tripu commented Feb 3, 2017

https://api.w3.org/functions seems ordered by IDs; not numerically but lexicographically.

I suggest order by title instead.

@tripu
Copy link
Member Author

tripu commented Feb 7, 2017

https://api.w3.org/groups/55181/participations?embed=true seems also sorted by numeric ID, but lexicographically (eg, 10 < 9), which is of little use.

@jean-gui
Copy link
Contributor

jean-gui commented Feb 9, 2017

Actually, there is no sorting at all except for the ones you listed as sorted by family name (which is actually not intentional but comes from a piece of code that does it but shouldn't (IMO)).

My first thought is that sorting should be done client-side, but this is flawed since you couldn't sort paginated results (unless you first retrieved all pages) so I think it is a good idea to add a server-side sorting feature, configurable through the query string. I am not sure how difficult this will be and how long it will take to implement.

@tripu
Copy link
Member Author

tripu commented Feb 9, 2017

I have a vested interest in having human-friendly sorting implemented server-side (for my API clients). But, to be honest, pagination doesn't need friendly sorting — it just needs to be deterministic, predictable.

For example, you could sort everything, always, by the SHA-1 checksum of their primary key, and paginated queries to the API would always return the same results, in the same order. I think that's the only thing that matters to keep consistency on the clients. If a client needs a different order, it should retrieve all pages first, then sort the whole set itself.

That being said… 👍 to sorting sensibly on the server by default, or by passing additional parameters in the request! It'll save me some work! 😄

@jean-gui
Copy link
Contributor

jean-gui commented Feb 9, 2017

My apologies, I wasn't clear at all. The way lists are sorted is deterministic, it's just that they are sorted in the order rows were entered in the database. In SQL, if you run "SELECT * from foo;" you will always get results in the same order, it's just usually not any useful order.

@tripu
Copy link
Member Author

tripu commented Feb 10, 2017

@jean-gui: OK, understood. I'll wait for you guys to evaluate this feature request, then.

@tripu
Copy link
Member Author

tripu commented Oct 19, 2017

So, is it on the road map to sort vectors sensibly before serving them, or shall I start implementing that on my clients…?

@jean-gui
Copy link
Contributor

Unfortunately, I don't have time to work on that feature.

@tripu
Copy link
Member Author

tripu commented Oct 20, 2017

Understood, @jean-gui!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants