How to sort a 2D unpacked array

I am trying to sort a 2D array using the code below:


function sort2dArray(int myArray[][])begin
  myArray.sort();
end

However I got error messages from the simulator:


Error-[IAMC] Invalid array manipulation method call
Wrong usage of array manipulation method 'sort' as this method is not allowed on multidimensional arrays.

Is there any way to sort a 2D array based on the value of rows?
I would like to achieve something similar to this:
function input: ‘{’{2, 3}, '{4,3}, '{1, 5}}
function output: ‘{’{1, 5}, '{2,3}, '{4, 3}}
(The array is sorted in an ascending order: 1,2,4)

In reply to theelmtree:

Use the with() clause to select the criteria for sorting.

module top;
  
  int myArray[][] =  '{'{2, 3}, '{4,3}, '{1, 5}};
  
  initial begin
    myArray.sort() with (item[0]);
    $display("%p",myArray);
  end
endmodule

In reply to dave_59:

Hi Dave,

Does item[0] here represent all the first column elements? could you please breakdown how the sort with item[0] works here? if I do item[1] will it consider 2nd column elements?

Thanks.

In reply to kuki2002:

Yes if you use item[1] it will sort as per 2nd column