Ad
  • Custom User Avatar

    Max for values only works with numbers, you are working with strings. The max function with strings returns the highest ascii character, "6" is bigger than "524" in terms of ascii range, looking at the zeroth index first.

    For example:
    To sort numbers we look at the zeroth index and their place-value. 524 is bigger than 6 because 500 is bigger than 006.
    However sorting strings is different because "6" is bigger than "5" in the sequence of "0123456789".

    You need to make it so that it converts the strings to numbers and then sort it.