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:
Sorted
would 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
[]T
or[n]T
,HOW_TO_SORT
is optional, it defaults to 1, and can be:1
or anyint
> 0: checks the slice/array is ordered in ascending order;-1
or anyint
< 0: checks the slice/array is ordered in descending order;func (a, b T) bool
returning true ifa < b
: checks the slice/array is ordered according to the function passed;[]string{"FIELD1", "FIELD2", …}
: only ifT
is 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.SortableValues
does.Examples of use:
Beta Was this translation helpful? Give feedback.
All reactions