sort upper case just before lowercase key values from a hash

后端 未结 4 1605
情书的邮戳
情书的邮戳 2020-12-07 03:36

I have an hash and i want to sort based on the keys with upper case words appearing just before the lowercase words.

Example:

JANE
jane
JIM

4条回答
  •  余生分开走
    2020-12-07 04:13

    Try:

    @list = ("jane","JIM","JANE","jim");
    print sort { uc $a cmp uc $b or $a cmp $b } @list;
    

提交回复
热议问题