How to sort a coll with multiple data points?

Brian Daurelle's icon

Hi, all, I'm (still) trying to perfect a coll-based system of playing back a pattern of stored MIDI data. Each "note" or entry of the coll contains multiple data that help determine the note. Each entry is: "scale degree", octave, tonic, mode, velocity. I am trying to add in the ability to sort it low-to-high, or high-to-low, but since each resulting note is a product of degree/octave/tonic, I can't just use the coll's sort function. My best option seems to be calculating the resulting pitches separately, then using zl.sort to get an indexes list, but I now can't figure out how to re-order the coll according to that list. Example attached.
Thanks!

Max Patch
Copy patch and select New From Clipboard in Max.

11OLSEN's icon

One way might be to append the pitches to the coll, then sort the coll according to this column.

Max Patch
Copy patch and select New From Clipboard in Max.

Brian Daurelle's icon

Figured it out! Posting an abstracted version here for posterity.

Max Patch
Copy patch and select New From Clipboard in Max.