11 lines
303 B
TypeScript
11 lines
303 B
TypeScript
/**
|
|
* Basic string compare (good for sorting)
|
|
* strcmp('abc', 'abc') -> 0
|
|
* strcmp('def', 'abc') -> 1
|
|
* strcmp('abc', 'def') -> -1
|
|
* See also: https://stackoverflow.com/q/1179366
|
|
*/
|
|
export default function strcmp(a: string, b: string): 0 | 1 | -1 {
|
|
return ((a === b) ? 0 : ((a > b) ? 1 : -1));
|
|
}
|