Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Input: An array containing the movie titles
- Declare titles as array
- Set i,j,minIndex, temp as integers
- for( set i=0; if i<titles.length-1; increment i)
- {
- set String min = titles[i];
- set minIndex = i;
- for(set j = i + 1; if j < n; increment j)
- {
- // If the current array selection is less than the min, swap places
- if(min.charAt(0) > titles[j].charAt(0))
- {
- set minIndex = j;
- }
- set titles[minIndex] =titles[i];
- }
- }
- return titles awway
Add Comment
Please, Sign In to add comment