Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • \$\begingroup\$ If you are allowed to accept a list of strings instead, you can shorten this to lambda s:s==sorted(s,key=`s`.find) \$\endgroup\$ Commented Apr 12, 2016 at 0:19
  • \$\begingroup\$ Ah, I tried taking a list, but I didn't think of using backticks... I'll ask the OP. \$\endgroup\$ Commented Apr 12, 2016 at 0:22
  • \$\begingroup\$ Am I missing something - why can't you just use s.find? \$\endgroup\$ Commented Apr 12, 2016 at 4:31
  • \$\begingroup\$ @immibis s has to be a list of singleton strings (or I'd have to cast s to list for the comparison), and list.find is not defined... \$\endgroup\$ Commented Apr 12, 2016 at 4:33
  • \$\begingroup\$ @Dennis s.index then? Seems to work for me. \$\endgroup\$ Commented Apr 12, 2016 at 4:37