(array: string[], order: string[])
| 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) =>{ |
no test coverage detected