This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
You could create a wrapper class for your variable-name / value pair like this:
provide hashCode() and compareTo() methods based on Integer values, then create an ArrayList of these wrapper objects
and sort this ArrayList with Collections.sort method. Finally, iterate trough the array and print name / value pairs.
You could also create an array of these objects and sort it with Arrays.sort.