Creates a comparator function for string-based sorting with locale-aware
comparison.
Generates a comparator that extracts string values from objects and
performs lexicographic comparison using locale-sensitive string comparison.
Supports both single strings and arrays of strings for multi-field sorting
scenarios.
When comparing arrays, performs lexicographic ordering: compares the first
elements, then the second elements if the first are equal, and so on. This
enables complex sorting like "sort by last name, then by first name".
// Single field sorting users.sort(GaffComparator.strings(user=>user.lastName)); // Result: Doe, Doe, Smith
// Multi-field sorting: last name, then first name users.sort(GaffComparator.strings(user=> [user.lastName, user.firstName])); // Result: Doe Jane, Doe John, Smith Bob
// Status-based sorting users.sort(GaffComparator.strings(user=>user.status)); // Result: active users first, then inactive
// Complex multi-field: status, then last name, then first name users.sort(GaffComparator.strings(user=> [user.status, user.lastName, user.firstName]));
// Integration with API sorting validation awaitTestValidator.sort("user name sorting")( (sortFields) =>userApi.getUsers({ sort:sortFields }) )("lastName", "firstName")( GaffComparator.strings(user=> [user.lastName, user.firstName]) )("+");
Creates a comparator function for string-based sorting with locale-aware comparison.
Generates a comparator that extracts string values from objects and performs lexicographic comparison using locale-sensitive string comparison. Supports both single strings and arrays of strings for multi-field sorting scenarios.
When comparing arrays, performs lexicographic ordering: compares the first elements, then the second elements if the first are equal, and so on. This enables complex sorting like "sort by last name, then by first name".
Example