list<Integer> integerList =new list<Integer>{7, 21, 45, 6,34,56,78,26,65,87,95};
// DESCENDING ORDER
for(Integer i = 0 ; i < integerList.size() ; i ++) {
for(integer j = i+1 ; j <= integerList.size() -1 ; j ++ ){
integer x = 0 ;
if(integerList[i] < integerList[j]){
x = integerList[i] ;
integerList[i] = integerList[j] ;
integerList[j] = x;
}
}
}
system.debug(integerList) ;
system.debug('Ssize: '+integerList[1]);
No comments:
Post a Comment