The JavaScript exception "invalid Array.prototype.sort argument" occurs when the argument of Array.prototype.sort() (and its related methods: Array.prototype.toSorted(), TypedArray.prototype.sort(), TypedArray.prototype.toSorted()) isn't either undefined or a function which compares its operands.... Examples Invalid cases js [1, 3, 2].sort(5); // TypeError...toSorted("name"); // TypeError Valid cases js [1, 3, 2].sort(); // [1, 2, 3]...