The direct selection sort of Java sort

Source: Internet
Author: User
public class Selectsort {public     static void Selectsort (int [] a) {int min; int temp;  if (A==null | | a.length<=0) {return;}  for (int i=0;i<a.length;i++) {//Outer loop controls the number of times, each time a minimum value is found and the interchange min=i;//defines the current subscript as the lowest value subscript for (int j=i+1;j<a.length;j++) {/ /Inner loop control the comparison between the current trip data find the minimum if (A[j]<a[min]) {//If there is a data in this trip that is less than the minimum value we define then assigns the subscript to min, in fact min is a flag min=j;}  }   if (min!=i) {//If the min in this trip has changed, then the data in this trip is smaller than the min we defined so the data is exchanged with our definition of a[min] temp=a[min]; a[min]=a[i]; a[i]=temp;}}    }

The direct selection sort of Java sort

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.