# Three sorting methods

Source: Internet
Author: User

Today I want to share with you three sorting methods: Select sorting, direct sorting, and Bubble sorting. For these sorting methods, I feel a bit fuzzy and I have compared them, I am not familiar with direct sorting. If you have any knowledge, I 'd like to explain it to you. These methods are mainly sorting, some are not repeated, and some are repeated.

Method 1: select the sorting method option explicit

Option base 1 private sub cmdsort_click () dim A (10) as integer, temp as integer dim I as integer, J as integer randomize for I = 1 to 10 a (I) = int (RND * 100 + 1) text1 = text1 & STR (A (I )) next I for I = 1 to 10 for J = I + 1 to 10 if a (I) <A (j) Then temp = a (I) = a (j) A (j) = temp end if next J print a (I) Next I end sub Method 2: direct sort option explicitoption base 1 private sub cmdsort_click () dim A (10) as integer, temp as integer dim I as integer, J as integer randomize for I = 1 to 10 a (I) = int (RND * 100 + 1) text1 = text1 & STR (A (I) Next I for I = 1 to 10 for J = I + 1 to 10 if a (I) <A (j) then temp = a (I) = a (j) A (j) = temp end if next J print a (I) Next I end sub method 3: bubble sort option explicitoption base 1dim A (10) as integer, temp as integer, I as integer, J as integer, P as string, flag private sub commandementclick () 'sort for I = 1 to 9 for j = 1 to 10-I if a (j) <A (J + 1) Then temp = a (j): A (j) = a (J + 1): A (J + 1) = temp end if next J next I for I = 1 to 10 print a (I) next I end subprivate sub command2_click () randomize P = "" for I = 1 to 10 a (I) = int (RND * 100 + 1) flag = 0 for j = 1 to I-1 if a (I) = a (j) then flag = 1 I = I-1 exit for end if next J if flag = 0 then print a (I) end if next I end sub
Related Keywords:

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.