Heap Sorting and Comparator Usage
Heap Sorting
Given a unsorted array, heap sort transforms it into a descending sequence:
Convert the array into a max heap using heap insertion or heapify operations
Repeatedly swap the root element with the last position, reduce heap size, and re-adjust
Continue untill heap size reduces to zero
Heap Construction Methods
Forward Traversal wit ...
Posted on Sat, 06 Jun 2026 16:25:05 +0000 by will35010
Demystifying the Array.prototype.sort Comparator
While patching a legacy Beego dashboard I stumbled on a tiny sorting requirement that refused to cooeprate. The goal sounded trivial: given an array that mixes one-, two- and three-digit integers, keep the global ascending order but push every two-digit value to the tail.
const sample = [1, 8, 3, 11, 100, 15, 201];
// expected: [1, 3, 8, 100, 2 ...
Posted on Sun, 17 May 2026 08:30:11 +0000 by dolphinsnot