Python implements selection sorting

巴扎黑
Release: 2016-12-07 10:53:05
Original
1335 people have browsed it

#!/usr/bin/env python

#coding=utf-8

#ChooseSort.py

#user can choose sort style: desc(1) or asc(2)

import stdinInput

def chooseSort( sortArray):

    arrayl=len(sortArray)

    if(arrayl<1):

        return

    

    for i in xrange(0,arrayl-1):

        min=i;

        for j in xrange(i+1,arrayl):

            if(sortArray[j]

                min=j

        sortArray[i],sortArray[min]=sortArray[min],sortArray[i]


if __name__=='__main__':

    stdinInput.stdinInput()

    chooseSort(stdinInput.intsortArrays)

    print stdinInput.intsortArrays


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!