Added methods to sort the Matrix class in different ways.