IMPORTANT NOTICE: Please be advised that the Verification Academy Forums will be offline for scheduled maintenance on Sunday, March 23rd at 4:00 US/Pacific.
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)
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?