Sorted #164
maxatome
started this conversation in
Suggestions for new operators
Sorted
#164
Replies: 1 comment
-
|
Implemented in branch sort, doc & tests to be completed, examples to be done. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
usage:
Sortedwould be an operator allowing to check whether a slice or an array is sorted or not.Accepted input: any slice or array.
If the input is
[]Tor[n]T,HOW_TO_SORTis optional, it defaults to 1, and can be:1or anyint> 0: checks the slice/array is ordered in ascending order;-1or anyint< 0: checks the slice/array is ordered in descending order;func (a, b T) boolreturning true ifa < b: checks the slice/array is ordered according to the function passed;[]string{"FIELD1", "FIELD2", …}: only ifTis a struct or a pointer on a struct, checks the slice/array of structs is ordered by struct fieldFIELD1, then by fieldFIELD2, …Fields can be prefixed by "-" to specify a descending order instead of ascending default one.
Default sorting would be handled the same way
tdutil.SortableValuesdoes.Examples of use:
Beta Was this translation helpful? Give feedback.
All reactions