UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

26 lines (23 loc) 602 B
/*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ "use strict"; (() => { // 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; } })();