A builder for comparator functions, similar in style to Java's Comparator.comparing(), written in and made for Typescript.
typescript
ComparatorBuilder.comparing(person => person.name).build();
`
Multi-Level comparison comparing the persons first name and then the person's last name.
`typescript
ComparatorBuilder.comparing(person => person.firstName).thenComparing(person => person.lastName).build();
`
Null-Tolerant sorting, where non-null values are priorized
`typescript
ComparatorBuilder.comparing(person => person.title).definingNullAs(NullMode.LOWEST).build();
`
Inversed comparison
`typescript
ComparatorBuilder.comparing(person => person.lastName).thenComparing(person => person.firstName).inverse().build();
`
The inverse comparison inverts the final comparison result, not the individual ones.
Null Safety ##
Because typescript does not (yet) provide a null-safe navigation operator, the nullSafe() exists. With nullSafe(),
a key extractor can be secured against null or undefined.
`typescript
ComparatorBuilder.comparing(nullSafe(person => person.employer.name)).definingNullAs(NullMode.HIGHEST).build();
``