Ruby - Enumerable and Collection Processing
Why does
sort_by often perform faster than sort with a block for complex sorting?sort_by often perform faster than sort with a block for complex sorting?sort_by creates an array of keys by applying the block once per element.sort with block compares elements multiple times, recalculating keys repeatedly.sort_by computes keys once before sorting -> Option Bsort_by computes keys once before sorting [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions