MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / basic_comparator

Function basic_comparator

shared/common-utils.ts:55–63  ·  view source on GitHub ↗
(a: T, b: T)

Source from the content-addressed store, hash-verified

53
54// For Array.prototype.sort
55export function basic_comparator<T>(a: T, b: T) {
56 if (a < b) {
57 return -1;
58 }
59 if (a > b) {
60 return 1;
61 }
62 return 0;
63}
64
65// https://stackoverflow.com/questions/41253310/typescript-retrieve-element-type-information-from-array-type
66export type ElementType<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer T)[] ? T : never;

Callers 1

findMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected