solve list of names python bubble method

-3

Good I have a job to do programming in python I have half finished but I need help with the bubble method to order a list of alphabetically given nonbres by the user I have the part of the list asking the user the names eh print them but the bubble motu I understand that only serves in names, a recommendation that I listen is to put the method brubuja with ascii but I do not understand how it works ascii I'll give you an example at the end thanks for your help:

example:

"Put a name"

Juan

Alejandro

Esmeralda

Kevin

Result: "4 numbers were given"

Alejandro

Esmeralda

Juan

Kevin

    
asked by Spiral 01.11.2016 в 17:57
source

1 answer

0

It's very simple, you just have to know how to do bubble sorting here I put a piece of code that does the ordering, I do not know if it serves but you can try it and adapt it to what you need.

 def ordenamientoBurbuja(lista,tam):
      for i in range(1,tam):
          for j in range(0,tam-i):
              if(lista[j] > lista[j+1]):
                     k = lista[j+1]
                     lista[j+1] = lista[j]
                     lista[j] = k;

As I say, I do not know if it works, I've written it here and I do not have a way to prove it.

    
answered by 01.11.2016 в 21:39