tengo icon indicating copy to clipboard operation
tengo copied to clipboard

Sorting

Open kcsampson opened this issue 2 years ago • 4 comments

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")

kcsampson avatar Nov 04 '22 19:11 kcsampson

@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.

NAICOLAS avatar May 15 '23 11:05 NAICOLAS

+1!

rohennes avatar May 15 '23 11:05 rohennes

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

geseq avatar May 15 '23 11:05 geseq

@ganehag Let's make this happen. :)

NAICOLAS avatar May 15 '23 12:05 NAICOLAS