Sorted Array from row wise column wise sorted matrix