2.29 Sort each row (on its own) in a matrix

Given

     4     2     5 
     2     7     9 
    10     1     2
 

Sort each row on its own, so that the result is

     2     4     5 
     2     7     9 
     1     2     10
 

Mathematica

mat={{4, 2,5}, 
     {2, 7,9}, 
     {10,1,2}}; 
Map[Sort[#]&,mat]
 

{{2, 4, 5}, 
{2, 7, 9}, 
{1, 2, 10}}
 

 

Matlab

A=[4  2 5; 
   2  7 9; 
   10 1 2]; 
sort(A,2)
 

     2     4     5 
     2     7     9 
     1     2    10
 

 

Maple

restart; 
A:=Matrix([[4,2,5],[2,7,9],[10,1,2]]); 
map(x->convert(sort(x),list),[LinearAlgebra:-Row(A,[1..-1])]); 
Matrix(%); 
 
#or, may simpler is 
 
restart; 
A:=Matrix([[4,2,5],[2,7,9],[10,1,2]]); 
for n from 1 to LinearAlgebra:-RowDimension(A)  do 
    A[n,..]:=sort(A[n,..]); 
od: 
A
 

Matrix(3, 3, [[2, 4, 5], 
              [2, 7, 9], 
              [1, 2, 10]])
 

 

I had to convert each row to a list above for this to work. But for the case of columns (see last item earlier), this was not needed. Strange that one can’t not construct a Matrix from list of Row vectors as with a list of Column vectors.

Maple 2021.