MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / sortArrayByIndex

Method sortArrayByIndex

src/danfojs-base/shared/utils.ts:744–755  ·  view source on GitHub ↗

* Returns the index of a sorted array * @param arr1 The first array * @param arr2 The second array * @param dtype The data type of the arrays * * @returns sorted index

(arr1: ArrayType1D | ArrayType2D, arr2: ArrayType1D | ArrayType2D, dtype: string)

Source from the content-addressed store, hash-verified

742 * @returns sorted index
743 */
744 sortArrayByIndex(arr1: ArrayType1D | ArrayType2D, arr2: ArrayType1D | ArrayType2D, dtype: string) {
745 const sortedIdx = arr1.map((item, index) => {
746 return [arr2[index], item];
747 });
748 if (dtype == "string") {
749 sortedIdx.sort();
750 } else {
751 sortedIdx.sort(([arg1], [arg2]) => (arg2 as unknown as number) - (arg1 as unknown as number));
752 }
753
754 return sortedIdx.map(([, item]) => item) as number[]
755 }
756
757 /**
758 * Returns a new series with properties of the old series

Callers 1

sortValuesMethod · 0.80

Calls 2

sortMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected