Hi!! :)
Can someone help
me to write a code that with sort through a list of strings which are peoples names
without using the python sort function.

So the rules are :

We start with an initial pile containing only the first name in the list.

Go through all the other names in the list from left to right and place each name on top of the left most
pile for which it is less than the name on top of this pile. If there is no such pile, we create a new pile
containing this name to the right of the other piles.

Until all the piles are empty, we repeatedly select and remove the smallest name among all those on top
of the pile.

The code I have so far is :

def psort(L):

M = [L[0]]

for i in L[1:]:

J = [M[0]]

print J

if J > i:

M = M +[i]

else:

create a new pile

M = [i] + M

print M

I was wondering how would I create new lists , since I do not know in the beginning how many piles/lists
will be needed.

Thanks ;) Rouby + Mona
Ps= CS is killing us any help would be appreciated :'(

You need correct indention. Then you can post any code in a Code block.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.