UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

20 lines (16 loc) 422 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function sortByStr(list, key, reverse) { if (reverse === void 0) { reverse = false; } list.sort(function (a, b) { var valueA = key ? a[key] : a; var valueB = key ? b[key] : b; if (reverse) { return valueB.localeCompare(valueA); } return valueA.localeCompare(valueB); }); } exports.sortByStr = sortByStr;