# Compare Functions in MR-lib

© 2012, Martin Rinehart

`compare_nocase()`

array.sort( compare_nocase(a, b) );

Compare copies of two strings, both converted to uppercase. Returns 1 if the first is greater, 0 if the two are equal, -1 if the second is greater (for use in sorts).

`compare_numbers()`

array.sort( compare_numbers(a, b) );

Compare two numbers. Returns 1 if the first is greater, 0 if the two are equal, -1 if the second is greater (for use in sorts).

`compare_numbers_and_strings()`

rows.sort( compare_numbers_and_strings(a, b) );

Compare database fields. If one is a number, it is "greater". If neither is a number, they are compared as strings. If they are equal, returns -1 (second is greater) to preserve order of the original records.

`compare_reverse()`

array.sort( compare_reverse(a, b) );

Compare numbers/strings in a database in descending order. Returns negation of the result of `compare_numbers_and_strings()`

.

Feedback: MartinRinehart at gmail dot com

# # #