![](/img/trans.png)
[英]Comparable custom types which can be sorted as array items without defining an additional compare function inside sort()
Python 和 Java 等語言具有對自定義類進行排序的特殊方法。 在 JavaScript 中, toString()可以被覆蓋,但這對於數值來說並不容易。 作為解決方法,我向類添加了一個名為compareTo()的方法,盡管這仍然需要一個函數來調用它。 class NumericSorta ...