Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList Manipulation

 
Dave DiRito
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this problem I need to find the smallest integer in an ArrayList and move it to the front of the list without changing the order of the other list elements. I created the code to find the smallest value. I just can't figure out how to move it to the front of the list. Here's my code so far:
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you know what index in the ArrayList the smallest element occupies right? So the next step is to remove it and add it at the first index in the ArrayList.
 
Dave DiRito
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again, Garrett. I was making it way harder than necessary. Now it seems so obvious.

Thank you,
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic