Ordered intersections

You can preserve the order of the first set by transforming it to an ordered set:

const myOrderedIntersection = myFirstSet
.sort()
.intersect(mySecondSet);

console.log('myOrderedIntersection', myOrderedIntersection.toJS());
// -> myOrderedIntersection [ 2, 4, 6 ]

This works because myFirstSet is now an ordered set. When you sort it, it returns an OrderedSet which remains sorted when the intersect() method iterates over it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.174.239