It looks like you have not told us your exact requirements and in the context of your problem the best solution could be to convert the 2 dimensional array into a one dimension array of 5X2 elements and then sort it.