tengo
tengo copied to clipboard
Sorting
I would like sort an array of objects based on a supplied function. Something like sort.Slice()
sorting := import("sorting") myList := [{x:1}, {x:2},{x:3}] sorting.sort( myList, func( i, j ){ return myList[i].x < myList[j].x }
The problem is, you can run a CompiledFunc for your UserFunc.
My workaround was to pass the name of a field to the UserFunc...
sorting.sort( myList, "x")
@geseq Do you have any updates? :) Would be great to be able to sort things. Was about to sort an array of timeseries, and realized this possibility isn't available.
+1!
The author of the PR hasn’t really responded to the change request. Happy to look into this if someone else would like to pick up
@ganehag Let's make this happen. :)