MATLAB: How to sort array of time format from min to max time value

arraysorttime format

Hi all,
I have a 2-dimension array which its elements are time format, such as 22:13:98. I want to sort each row of this array in the ascending format, I mean from minimum time to maximum time. Any help is appreciated.

Best Answer

  • help sort
    Example:
    A = magic(5);
    sort(A,2)
    If you want to convert your time data to a numeric representation for sorting, try datenum.
    help datenum
    Example:
    datenum('22:13:98','hh:mm:ss')