Open tripu opened 7 years ago
https://api.w3.org/functions
seems ordered by IDs; not numerically but lexicographically.
I suggest order by title instead.
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.
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.
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… :+1: to sorting sensibly on the server by default, or by passing additional parameters in the request! It'll save me some work! :smile:
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.
@jean-gui: OK, understood. I'll wait for you guys to evaluate this feature request, then.
So, is it on the road map to sort vectors sensibly before serving them, or shall I start implementing that on my clients…?
Unfortunately, I don't have time to work on that feature.
Understood, @jean-gui!
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:
https://api.w3.org/specifications
: random order, apparently; sort bytitle
?https://api.w3.org/groups/32061/specifications
.https://api.w3.org/affiliations?embed=true
: sorted numerically byid
(not very useful); sort byname
instead?These three seem to be by
family
(good):https://api.w3.org/groups/32061/users?embed=true
https://api.w3.org/groups/32061/chairs?embed=true
https://api.w3.org/groups/32061/teamcontacts?embed=true
.But these two are not sorted (?):
https://api.w3.org/participations/1503/participants?embed=true
https://api.w3.org/affiliations/52794/participants?embed=true
.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?