---
title: "选择排序算法分析"
author: "greenwen"
date: "2012-10-18T16:02:28Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2012-10-18T15:56:11Z"
id: 1701056
url: "https://superivan.iteye.com/blog/1701056"
---

<span style="color:red">基本思想：</span>在要排序的一组数中，选出最小的一个数与第一个位置的数交换；
然后在剩下的数当中再找最小的与第二个位置的数交换，如此循环到倒数第二个数和最后一个数比较为止。


```java

public int[] selectSort(int[] selectSortArray){
   int position=0;

   for(int i=0;i<selectSortArray.length;i++){
       position=i;

       int temp=selectSortArray[i];

       for(int j=i+1; j<selectSortArray.length; j++){
           if(selectSortArray[j] < temp){
              temp=selectSortArray[j];
              position=j;
           }
       }
       
       selectSortArray[position] = selectSortArray[i];
       selectSortArray[i]=temp;
   }
   return selectSortArray;
}


```