question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specifying a sort order when returning unique values

See original GitHub issue

As discussed https://github.com/data-apis/array-api/pull/25#issuecomment-681129564, we need to resolve if, and how, we should specify a sort order when returning unique values.

A corollary issue is, if we support an optional keyword to return sorted unique values, whether we should also support specifying the sort direction (ascending vs descending).

We could limit sorting to ascending order, but that this may be considered an arbitrary restriction may lend support for the argument of not returning ascending/descending sorted output at all. Instead, punting sorting to userland, where sort order can be specified via sort(). However, as discussed in the OP, combining unique/sort may allow implementation perf optimizations which cannot be replicated when performed as two separate steps.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
asmeurercommented, Jan 4, 2021

Sorting is also not well defined for complex dtypes (potentially for other advanced dtypes as well if those were ever added). See https://github.com/data-apis/array-api/issues/102#issuecomment-748328170. I’m not clear what the final resolution of that is, but it sounds like the sort function and friends require additional complexity to properly handle complex numbers (e.g., a key parameter). So it would probably be a good idea to omit sorted from any non-sorting API functions, as they would also have to support those additional parameters to be usable with complex dtypes.

0reactions
rgommerscommented, Jan 4, 2021

Makes sense, thanks @asmeurer. There are no other sorted keywords at the moment other than in unique (which gh-104 removes).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Return sorted unique values from array, but if count is equal ...
The cause of this reordering is that object properties that are numerical will come out ordered when using Object.keys() .
Read more >
Extract a unique distinct list sorted from A to Z - Get Digital Help
The array formula in cell D3 extracts unique distinct values sorted A to Z, from column B to column D. Unique distinct values...
Read more >
Excel UNIQUE function - fastest way to find unique values
Formula examples to extract unique values from a range, based on multiple criteria, sort the results alphabetically, and more.
Read more >
Unique values in array - MATLAB unique - MathWorks
Find the unique rows of A . unique returns the rows of A in sorted order by the first variable Age and then...
Read more >
Unique Tool | Alteryx Help
For best results, uncheck the Use Dictionary Order setting in the Sort tool configuration and sort on all the fields selected in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found