UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

25 lines (21 loc) 582 B
/*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ // src/sortByKey.ts var SortDirection = /* @__PURE__ */ ((SortDirection2) => { SortDirection2["ASC"] = "ASC"; SortDirection2["DESC"] = "DESC"; return SortDirection2; })(SortDirection || {}); function sortByDate(a, b, key, direction = "ASC" /* ASC */) { if (a[key] < b[key]) { return direction === "ASC" /* ASC */ ? 1 : -1; } if (a[key] > b[key]) { return direction === "ASC" /* ASC */ ? -1 : 1; } return 0; } export { SortDirection, sortByDate };