一个排序的问题.每个10位排在一起..

来源:百度知道 编辑:UC知道 时间:2024/05/12 15:15:32
我上图..实在表达不清楚了...请各位帮帮忙

不管用sql java 都行了。。。

升序 我要的排序
1 1
2 11
3 21
4 2
5 12
6 22
7 3
8 13
9 23
10 4
11 14
12 24
13 5
14 15
15 25
16 6
17 16
18 26
19 7
20 17
21 27
22 8
23 18
24 28
25 9
26 19
27 29
28 10
29 20
30 30
在 ArrayList 里排 和 存储里都行

刚写的,热乎的:
public class Test {
public static void main(String[] args){

ArrayList al = new ArrayList();
for(int i=1;i<=30;i++){
al.add(i+"");
}
Object [] ar = al.toArray();

test2(ar);

for(int l=0;l<ar.length;l++){
System.out.println(ar[l]);
}
}

public static void test2(Object [] o){
for(int k=0;k<o.length;k++){
for(int i=0;i<o.length-1;i++){
if(can3(o[i],o[i+1])){
Object temp =o[i];
o[i]=o[i+1];
o[i+1]=temp;
}
}
}
}

public static boolean can3(Object o1,Object o2){
int i1 = Integer.parseInt((String)o1);
int i2 = Integer.parseInt((String)o2);
String s1 = (String)o1;
String s2 = (String)o2;
int b1 = i1%10;
int b2 = i2%10;
if(b1==0){
b1=10;
}
if(b2==0){
b2=10;
}