Added option to order by index

Added option to order matrix by index