+ 4
Sorting Working Python
I have tried making sorting the number list, https://code.sololearn.com/cMKtKArcBenY/ and I dont know, what algorithm is it called because I coded it thinking its algorithm myself. But it doesnt sort the numbers well. It works up to some extent, i.e 30% Any suggestion how to solve it?
12 Answers
+ 1
On line 25, replace
sort_prev_repeat(sorted_array)
with
sorted_array = sort_prev_repeat(sorted_array)
The algorithm you have implemented here is called "insertion sort", by the way.
+ 5
maf
I don't know. I created my own
+ 4
https://code.sololearn.com/cHRZdgMo9svV/?ref=app
Is that what you want ?
+ 2
Sarthak 🇳🇵 according to which algorithm are you trying to sort the list?
+ 2
Sarthak 🇳🇵 lol. If u explain me like what is ur desired output, then I would be probavly be able to solve the problem.
+ 2
Alfred Juma
No, I wanted to sort using my own sorting algorithm.
maf
Sorry, for for less-clarification of code. I'll try to provide you clarification tomorrow in a paper, and here it's time to sleep now.
+ 2
Schindlabua
It got solved both way
https://code.sololearn.com/cJ9M3KK8wHxR/?ref=app
+ 2
John Robotane
I know that. I was just trying to understand the algorithm that my brain uses to sort array. And just tried to implement that algorithm in python.
+ 1
Why not use the built in sort() or sorted()
+ 1
as Justus said it, it's better to use the built in fonctions, they are more optimized and avoid you headaches!
+ 1
alright, there is a Sololearn course about sorting:
https://www.sololearn.com/learn/774/?ref=app
0
Sarthak 🇳🇵 alright no prob