4

This is my code:

#这是一个有关旅行的程序
place=['北京天安门','西安兵马俑','香港游乐园','日本秋叶原']
print(place)
print(sorted(place))
print(place)

place.sorted(reverse=true)
print(place)

When I run my code, something Wrong happens.

place.sorted(reverse=true)

or

sorted(place)

Using the 2nd way, how can I give (reverse=true)?

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
I_love_python
  • 67
  • 1
  • 2
  • 7
  • 1
    It's either `sorted` (not inplace) or `list.sort` (which is inplace)`. In both cases they accept a `reverse` keyword argument. – cs95 Dec 11 '17 at 12:04
  • http://idownvotedbecau.se/noresearch/ - you could have solved this by yourself quite easily by reading the error message and the documentation, or even just googling for "python list sort reverse" – bruno desthuilliers Dec 11 '17 at 12:07
  • In python ,True & true is not different ?? I think True is correct .thank you very much – I_love_python Dec 11 '17 at 12:17

1 Answers1

6

Just use sorted(place, reverse=True).

Daniel
  • 2,195
  • 3
  • 14
  • 24