sorts a matrix by specified columns
creates a sorted index for a matrix
finds locations of unique BY groups in a sorted or indexed matrix