/ Published in: Java
This demonstrate the expressiveness of Groovy vs Java.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.*; // // Groovy version of "Sort keys by values" is: // keys.sort{ lang[it] } // That's one line replacement!!! // class MapSort { lang.put(0, "Java"); lang.put(1, "Groovy"); lang.put(2, "Ruby"); lang.put(3, "Python"); lang.put(4, "C#"); lang.put(5, "C++"); lang.put(6, "Perl"); //Sort keys by values. return leftValue.compareTo(rightValue); } }); //List the key value } } }