montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.1k stars 184 forks source link

updating the contentCompare in SortedSet #248

Open hyusetiawan opened 2 years ago

hyusetiawan commented 2 years ago

I am working with SortedSet, for my use case to keep sorted rows that will be presented on a table. As one would expect, clicking a column of the table would change the sort order, asc/desc, now the question is, how do I do this? I see there is a public function called contentCompare() do I just replace that and call splay(), something like

const sortedSet = new SortedSet(rows, identity, oldContentCompare)
sortedSet.contentCompare = newContentCompare
sortedSet.splay()

is this how it';s supposed to be? or is there a function I'm missing?