Given matrix
let matrix = [ ] ; let list1 = [ 9 , 7 , 4 , 5 ] ; let list2 = [ 1 , 6 , 2 , - 6 ] ; let list3 = [ 12 , 20 , 2 , 0 ] ; let list4 = [ - 5 , - 6 , 7 , - 2 ] ; matrix . push ( list1 ) ; matrix . push ( list2 ) ; matrix . push ( list3 ) ; matrix . push ( list4 ) ; sortBoundaryWise ( matrix ) ;