#!/usr/bin/python
# -*- coding: utf-8 -*-


def swap_elements(_list, to_index, from_index):
    _list[to_index], _list[from_index] = _list[from_index], _list[to_index]


def selection_sort(_list):
    _list = _list[:]
    list_length = len(_list)
    for i in range(list_length):
        least = i
        for j in range(i + 1, list_length):
            if _list[j] < _list[least]:
                least = j
        swap_elements(_list, least, i)
    return _list


def bubble_sort(_list):
    _list = _list[:]
    list_length = len(_list)
    for i in range(list_length):
        for j in range(list_length-1, i, -1):
            if _list[j] < _list[j-1]:
                swap_elements(_list, j, j-1)
    return _list
