Summary
In this chapter, you learned about the basics of sorting collections in Immutable.js. The basic sort() and reverse() methods sort values using a default comparator function. You can supply your own comparator functions for more complex scenarios. There's also the sortBy() method that accepts an iteratee function, which is used to return values that are passed to the comparator.
We then addressed the issue of sorting maps. Because they're a keyed collection, they have no inherent mechanism to keep track of the order of values. Lists, on the other hand, have this value built into them. Ordered maps are used to preserve the ordering of maps. You can also sort maps by keys if you use sortBy() to return the key.
We looked at the problem ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access