How to sort an array of objects with multiple field values in JavaScript

前端 未结 5 1845
迷失自我
迷失自我 2020-12-10 13:56

I found a great method to sort an array of objects based on one of the properties as defined at:

Sort array of objects by string property value in JavaScript

5条回答
  •  一整个雨季
    2020-12-10 14:12

    You may also want to have a look at thenBy.js: https://github.com/Teun/thenBy.js

    It allows you to use the standard Array.sort, but with firstBy().thenBy().thenBy() style.

提交回复
热议问题