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