Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Sorting Algorithm: Challenge

:warning: This is not a question, it is more of a challenge for anybody to try.

The challenge is to make an algorithm that sorts a list. It should order from smallest to largest, and, while any language is allowed, I personally prefer Python.

Also, no cheating! Don't look at other's answers before solving (if you are taking the challenge) or using any kind of sort built-in function! If there's a built-in function that already does sorting, please don't use that. The purpose of this challenge is to challenge yourself.

It isn't required, but to prove that you solved the challenge, you can post your code below.

Enjoy the challenge! ~Alex




:warning:SPOILER ALERT If you are taking the challenge, No peeking!!






1 Answer

I found a solution in Python:

def sort_list(list_):
    result_list = []
    data = list_
    while data:
        result_list.append(min(data))
        data.remove(min(data))
    return result_list