sort lexicographically python code example
Example 1: lexicographic order python
my_arr = [
"hello",
"apple",
"actor",
"people",
"dog"
]
print(my_arr)
my_arr.sort()
print(my_arr)
Example 2: lexicographic order python
my_arr = [
"hello",
"apple",
"actor",
"people",
"dog"
]
print(my_arr)
new_arr = sorted(my_arr)
print(new_arr)
print(my_arr)
Example 3: sort lexo python
def sortlexo(n):
w = []
for i in n:
w.append(i)
w.sort
w = w[::-1]
for i in w:
print(i,end = "")
for i in range(int(input())):
n= input()
sortlexo(n)