UNPKG

@ecomplus/utils

Version:

JS utility functions to E-Com Plus (not only) related apps

28 lines 1.11 kB
export default alphabeticalSort; /** * @method * @memberof ecomUtils * @name alphabeticalSort * @description Sort list of objects alphabetically by name ot title property. * @param {Array|Object.<string, *>} list - Array of objects (products, brands...) or list body with 'results' * @returns {Array} * * @example * // Sample array with name or title's property * ecomUtils.alphabeticalSort(['product', 'category']) * // => ["category", "product"] * ecomUtils.alphabeticalSort(['Matheus', 'Vitor', 'Ana', 'Clara', 'Bruna']) * // => ["Ana", "Bruna", "Clara", "Matheus", "Vitor"] * // Can be an array of objects like: * const brand1 = {name: 'zara'} * const brand2 = {name: 'Thermaltake'} * const brand3 = {name: 'AeroCool'} * const brand4 = {name: 'Fortrek'} * const array = [brand1, brand2, brand3, brand4] * ecomUtils.alphabeticalSort(array) * // => [{name: "AeroCool"}, {name: "Fortrek"}, {name: "Thermaltake"}, {name: "Thermaltake"}, {name: "zara"}] */ declare function alphabeticalSort(list: any[] | { [x: string]: any; }): any[]; //# sourceMappingURL=alphabetical-sort.d.ts.map