Sorting a vector gives back an ArraySeq with O(n) gets instead of O(log N) gets. This means it can be more efficient to take a vector, sort, then turn it back into a vector.
Cause:sort works by copying the collection to be sorted into an array, calls Arrays/sort to sort it, and then returns a seq on the sorted array. The seq returned is an ArraySeq and doesn't implement Indexed.
Alternatives:
1. Make ArraySeq (and primitive specializations thereof) implement Indexed, providing constant time lookup by index. 2. Specialize sorting for different collection types 3. ???
Sorting a vector gives back an ArraySeq with O(n) gets instead of O(log N) gets. This means it can be more efficient to take a vector, sort, then turn it back into a vector.
Cause:
sortworks by copying the collection to be sorted into an array, callsArrays/sortto sort it, and then returns a seq on the sorted array. The seq returned is an ArraySeq and doesn't implement Indexed.Alternatives:
1. Make ArraySeq (and primitive specializations thereof) implement Indexed, providing constant time lookup by index.
2. Specialize sorting for different collection types
3. ???