lexicographic order python

Solutions on MaxInterview for lexicographic order python by the best coders in the world

showing results for - "lexicographic order python"
Elias
07 Apr 2019
1my_arr = [
2"hello",
3"apple",
4"actor",
5"people",
6"dog"
7]
8
9print(my_arr)
10my_arr.sort()
11print(my_arr)
Adam
21 Jul 2020
1my_arr = [
2"hello",
3"apple",
4"actor",
5"people",
6"dog"
7]
8
9print(my_arr)
10# Create a new array using the sorted method
11new_arr = sorted(my_arr)
12
13print(new_arr)
14# This time, my_arr won't change in place, rather, it'll be sorted
15# and a new instance will be assigned to new_arr
16print(my_arr)