BoginjaSexk
New Member
I'm doing an assignment and I was wondering if there was an easy to move elements in an array around. I'm trying to sort a list of authors alphabetically, so I'd like to compare array[1] to array[2] and if 2 belongs in front of 1 I'd simply like to move it there. I figured the best way to do this would be by using two for loops. Here's basically what I have. Is there any easy way to move k in front of j in the array? \[code\]for(int j = 0; i > j; j++) { for(int k = 0; k > i; k++) { if(array[j].getAuthor.compareTo(array[k]) == -1) { //move k in front of j } else { //do nothing } } }\[/code\]