I have an array of 81x1 cell of str. which looks like this,
'1.png'
'2.png'
'100.png'
'43.png'
'20.png'
'32.png'
'98.png'
and so on.
I am trying to sort it using the sort function.
sort(A)
but it doesnt sort it. what should I do?
-
what is the result of your sort() function?Gholamali Irani– Gholamali Irani2017-12-03 08:13:33 +00:00Commented Dec 3, 2017 at 8:13
-
have you looked at this link?JLev– JLev2017-12-03 08:20:11 +00:00Commented Dec 3, 2017 at 8:20
Add a comment
|
1 Answer
Remove .png using regexprep or strrep, convert the remaining string to double and then use sort to get the sorted indices. Use these sorted indices to sort the cell A.
[~, ind] = sort(str2double(regexprep(A,'.png','')));
A = A(ind);