Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I want to sort a list of words alphabetically without using any built-in sorting methods. How would I go about doing this?

share|improve this question

put on hold as too broad by moooeeeep, Fengyang Wang, Moinuddin Quadri, juanpa.arrivillaga, Jim Fasarakis-Hilliard 16 hours ago

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

5  
Look up a sorting algorithm and implement it :-). You can find pseudo-code for all sorts of algorithms on wikipedia -- One of the easiest to understand (though not very performant) is called Bubble Sort. – mgilson 18 hours ago

Have a look at Wikipedia. For a homework assignment on your level, I guess, bubblesort is just fine. It is easy to understand and implement.

share|improve this answer

As pointed out in comment section, you can use bubble sort.

Bubble sort is one of the most basic sorting algorithm that is the simplest to understand. It’s basic idea is to bubble up the largest(or smallest), then the 2nd largest and the the 3rd and so on to the end of the list. Each bubble up takes a full sweep through the list.

def bubble_sort(items):
        """ Implementation of bubble sort """
        for i in range(len(items)):
                for j in range(len(items)-1-i):
                        if items[j] > items[j+1]:
                                items[j], items[j+1] = items[j+1], items[j]     # Swap!

For more information visit: http://danishmujeeb.com/blog/2014/01/basic-sorting-algorithms-implemented-in-python/

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.