Given matrix
List < List < int > > matrix = new List < List < int > > ( ) ; matrix . Add ( new List < int > ( new int [ ] { 9 , 7 , 4 , 5 } ) ) ; matrix . Add ( new List < int > ( new int [ ] { 1 , 6 , 2 , - 6 } ) ) ; matrix . Add ( new List < int > ( new int [ ] { 12 , 20 , 2 , 0 } ) ) ; matrix . Add ( new List < int > ( new int [ ] { - 5 , - 6 , 7 , - 2 } ) ) ; sortBoundaryWise ( matrix ) ; } }