I'm currently reading CRLS and implementing the algorithms in javascript.
In section 5.3 - Permute by sorting, I felt like a morron while trying to come up with an efficient implementation of the simple algorithm. Here is the pseudo-code:

Here is my implementation
Array.prototype.sortShuffle = function () {
const LENGTH = this.length;
const CUBE = Math.pow(LENGTH, 3);
let P = this
.map((e, i) => {
return {v: Math.floor(Math.random() * CUBE), e: e}
})
.sort((e1, e2) => e1.v > e2.v);
P.forEach((e, i) => this[i] = e.e);
}
I resorted to this sad solution because the native Array.prototype.sort doesn't provide the indexes in the comparator, A.sort((e1, e2, i1, i2) => ...) could have done the trick.
Can anyone please provide a more efficient solution (without implementing the sorting function above all)