0

# sort array from 1 to n python

how we can sort array from 1 to n python not from 0 to n Start from index 1 For example a = np.array([ 1 , 2 , 3]) not a[0] == 1 i want that index starts from 1 a [1] == 1

4 Answers

0

You can do this
sorted_list = sorted(old_list[1:])
This way will not include the 0 index element though, so you need to add back if required

0

thanks but i want a array not a list

0

It's the same, you can try it your own

0

Arrays start from 0. That's just a fundamental fact. If you want an indexed list that doesn't use array rules, you want to use a dictionary.
i = 1
fake_array = {}
for num in num_list = [1, 2, 3]:
fake_array[i] = num
i += 1
fake_array[1] == 1 #will be True

Hot today

difference in while loop

2 Votes

Somebody help me please ðŸ¥º

0 Votes

Kotlin get if Var doesn't exist

-1 Votes