MCPcopy Create free account
hub / github.com/Make-md/makemd / orderStringArrayByArray

Function orderStringArrayByArray

src/shared/utils/array.ts:49–68  ·  view source on GitHub ↗
(array: string[], order: string[])

Source from the content-addressed store, hash-verified

47
48
49 export const orderStringArrayByArray = (array: string[], order: string[]) =>{
50
51 return array.sort( function (a, b) {
52 const A = order.indexOf(a), B = order.indexOf(b);
53
54 if (A > B) {
55 if (A != -1 && B == -1) {
56 return -1
57 }
58 return 1;
59 } else {
60 if (B != -1 && A == -1) {
61 return 1
62 }
63 return -1;
64 }
65
66 });
67
68 };
69
70
71 export const orderArrayByArrayWithKey = (array: any[], order: string[], key: string) =>{

Callers 1

parseContextTableToCacheFunction · 0.90

Calls 1

sortMethod · 0.80

Tested by

no test coverage detected