Is there a shorter way to make this function?

后端 未结 7 993
鱼传尺愫
鱼传尺愫 2021-01-24 23:47

B. front_x Given a list of strings, return a list with the strings in sorted order, except group all the strings that begin with \'x\' first. e.g. [\'mix\', \'xyz\', \'apple\',

7条回答
  •  难免孤独
    2021-01-25 00:06

    The error for your return is because sort does not return a value, it merely modifies the list.

    This seems a fairly fast way to do this, it runs in linear time, you won't get much faster than that. That being said, you could do inline code to shorten it, but it's not always more readable that way.

提交回复
热议问题