Ad
  • Default User Avatar

    I think the answer is wrong, even though it can pass all tests.

    1. sorted(w) will sort every char in a word by ASCII order increasingly, and it will put digits ahead of letters, ie '0' '1'... '9'..'A'...'Z'..'a'..'z'
    2. asume we ignore consecutive numbers. if the test case is "is2 Thi1s T4est 3a 11h"
      Test.assert_equals(order("is2 Thi1s T4est 3a 11h"), "Thi1s is2 3a T4est 11h")
      And the test result will be '11h Thi1s is2 3a T4est' should equal 'Thi1s is2 3a T4est 11h'. sorted(w) will put '11h' ahead of 'Thi1s', which is not we wanted.
      sorted('11h') -> ['1', '1', 'h']
      sorted('Thi1s') -> ['1', 'T', 'h', 'i', 's']
      and, the second '1' in '11h' is less than 'T' in 'Thi1s', which is not we wanted.