MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / compareSortKeys

Function compareSortKeys

js/botasaurus-server-js/src/sorts.ts:44–65  ·  view source on GitHub ↗
(keyA: any, keyB: any)

Source from the content-addressed store, hash-verified

42 }
43
44 private compareSortKeys(keyA: any, keyB: any): number {
45 if (Array.isArray(keyA) && Array.isArray(keyB)) {
46 // Compare list (tuple equivalent) values
47 for (let i = 0; i < Math.min(keyA.length, keyB.length); i++) {
48 if (keyA[i] < keyB[i]) {
49 return this.reverse ? 1 : -1;
50 } else if (keyA[i] > keyB[i]) {
51 return this.reverse ? -1 : 1;
52 }
53 }
54 return this.reverse ? keyB.length - keyA.length : keyA.length - keyB.length;
55 }
56
57 // Compare other types of values
58 if (keyA < keyB) {
59 return this.reverse ? 1 : -1;
60 } else if (keyA > keyB) {
61 return this.reverse ? -1 : 1;
62 } else {
63 return 0;
64 }
65 }
66
67 public apply(data: any[]): any[] {
68 const copy = [...data];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected