Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
//
// Copyright (c) 2018-present, Cruise LLC
//
// This source code is licensed under the Apache License, Version 2.0,
// found in the LICENSE file in the root directory of this source tree.
// You may not use this file except in compliance with the License.
import natsort from "natsort";
const sortFn = natsort({ insensitive: true });
export default function naturalSort(key?: string) {
return key ? (a: any, b: any) => sortFn(a[key], b[key]) : sortFn;
}
import R from 'ramda';
import natsort from 'natsort';
const sortObjects = natsort();
/**
* Sort an array of objects by property.
*
* @param {String|Array} prop
* A property to sort by. If passed as an array, it
* will be treated as a deep property path.
*
* @param {Array} list
* An array of objects to sort.
*
* @return {Array}
* A sorted copy of the passed array.
*
* @example
* sortByProp('order', items);
(): Array => {
const sorter = natsort();
return cloneDeep(props.value.concat(available.value)).sort((a: TemplateVariable, b: TemplateVariable) =>
sorter(a.name, b.name),
);
},
);