1

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?

2
  • what is the result of your sort() function? Commented Dec 3, 2017 at 8:13
  • have you looked at this link? Commented Dec 3, 2017 at 8:20

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.