#!/usr/bin/env python # -*- coding:utf-8 -*- lst = [5,1,4,3,2] for i in range(len(lst) - 1): for j in range(i + 1, len(lst)): if lst[i] > lst[j]: lst[i], lst[j] = lst[j], lst[i] print('after sorted', lst)