Python Forum
sorted function example mystery
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sorted function example mystery
#1
The following code works, but I don't know why (I'm using python v 3.7.3)

print(f'{"".join(sorted("foo", key="of".index))}')
It correctly prints oof

I don't understand:
key="of".index
Reply


Messages In This Thread
sorted function example mystery - by sabaidii2 - Feb-10-2020, 02:23 AM
RE: sorted function example mystery - by DeaD_EyE - Feb-10-2020, 07:35 AM
RE: sorted function example mystery - by perfringo - Feb-10-2020, 07:39 AM
RE: sorted function example mystery - by sabaidii2 - Feb-10-2020, 09:05 AM
RE: sorted function example mystery - by DeaD_EyE - Feb-10-2020, 09:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Failing to print sorted files tester_V 4 1,245 Nov-12-2022, 06:49 PM
Last Post: tester_V
  set and sorted, not working how expected! wtr 2 1,281 Jan-07-2022, 04:53 PM
Last Post: bowlofred
Shocked An array "mystery": The same array, the same operations but different outcomes mewss 3 2,141 Feb-17-2021, 06:34 PM
Last Post: mewss
  How to make elements return sorted? notsoexperienced 4 3,218 Sep-24-2020, 09:00 AM
Last Post: perfringo
  Why is my original list also sorted? Pedroski55 1 1,610 Jul-15-2020, 09:25 PM
Last Post: Yoriz
  Outputting Sorted Text files Help charlieroberrts 1 1,725 Jul-05-2020, 08:37 PM
Last Post: menator01
  Byte array is sorted when sending via USB daviddlc68 1 2,820 Aug-16-2019, 10:11 AM
Last Post: wavic
  sorted object in list trois 2 2,250 Mar-04-2019, 09:12 AM
Last Post: trois
  [Help] sorted() in while loop with user's input() {Screenshot attached} vanicci 5 4,008 Aug-04-2018, 08:59 PM
Last Post: vanicci
  understanding sorted key parameter amirt 2 2,758 Jul-30-2018, 06:27 PM
Last Post: amirt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020