[Homework Project] How would I sort alphabetically in Python without using `sort()`?

I’m working on a project in Python I was given by someone. What happens is, I’m given three name:score pairs, and then I have to sort them however the user chooses: alphabetically, ascending scores, or descending scores. Right now, I’m just working on the alphabetic sorting. That’s easy, Python has a sort() function which I could use and be done with the challenge pretty quickly. But this where it gets hard:

You may not import any modules, and you may not call any sorting methods/functions.

I’m having a hard time figuring out how to sort the names alphabetically without a humongous chunk of inefficient, bloated, and annoying code.
Is anyone able to help me figure this out?

I’m doing this for fun, so don’t really need to keep to the rules, but I would like to as much as possible, and one of them is:

you may not use code from websites, so don’t bother looking any up.

So please keep that in mind and just poke me in the right direction, rather than showing me the complete code you would use :slight_smile:


1 Like

You will need to write a sorting algorithm, the easiest two are merge sort and bubble sort. Maybe a good starting point to learn something about them?


@stetim94 I’ve completed the hard part of the challenge now, so thanks :slight_smile:

You wrote a a a sorting algorithm? Which one did you choice? Good to hear you managed it :slight_smile:

@stetim94 I’ll share my solution with you in a PM.