물음표 살인마의 개발블로그

알고리즘 문제/CodeWar

Sort Arrays(Ignoring case)

BEstyle 2022. 11. 18. 14:28

DESCRIPTION:

Sort the given array of strings in alphabetical order, case insensitive. For example:

["Hello", "there", "I'm", "fine"]  -->  ["fine", "Hello", "I'm", "there"]
["C", "d", "a", "B"])              -->  ["a", "B", "C", "d"]

def sortme(words):
    print(words)
    temp=[]
    for i in range(len(words)):
        temp.append(words[i].lower())
    temp=sorted(temp)
    temp2=temp.copy()
    
    for i in range(len(words)):
        ind=temp.index(words[i].lower())
        temp2[ind]=words[i]
    return (temp2)

'알고리즘 문제 > CodeWar' 카테고리의 다른 글

Highest Rank Number in an Array  (0) 2022.11.19
Range Extraction  (0) 2022.11.18
Sum two arrays  (0) 2022.11.18
Triangle Number Check  (0) 2022.11.18
Pascal's Triangle #2  (0) 2022.11.17