Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Comparator;
- 2 import java.util.Random;
- 3
- 4 object Main {
- 5 val ARRAY_SIZE = 10;
- 6 val STRING_SIZE = 20;
- 7
- 8 def printTable(
- 9 sortedStringA: Array[String],
- 10 sortedIntegerA: Array[Integer],
- 11 sortedFloatA: Array[Float],
- 12 sortedStringD: Array[String],
- 13 sortedIntegerD: Array[Integer],
- 14 sortedFloatD: Array[Float],
- 15 sortType: String
- 16 ): Unit = {
- 17 println(String.format("%n%40s%n============================================================",
- 18 sortType + " Ascending"));
- 19 print(String.format("%n%" + STRING_SIZE + "s | %s | %17s%n",
- 20 "Sorted Strings", "Sorted Integers", "Sorted Floats"));
- 21 for(i <- 0 until ARRAY_SIZE){
- 22 print(String.format("%s | %17d | %17f%n",
- 23 sortedStringA(i), sortedIntegerA(i), sortedFloatA(i).toString));
- 24 }
- 25 println(String.format("%n%40s%n============================================================",
- 26 sortType + " Descending"));
- 27 print(String.format("%n%" + STRING_SIZE + "s | %s | %17s%n",
- 28 "Sorted Strings", "Sorted Integers", "Sorted Floats"));
- 29 for(i <- 0 until ARRAY_SIZE){
- 30 print(String.format("%s | %17d | %17f%n",
- 31 sortedStringD(i), sortedIntegerD(i), sortedFloatD(i).toString));
- 32 }
- 33
- 34
- 35 }
- 36 def main(args: Array[String]) {
- 37
- 38 object IntegerComparator extends Comparator[Integer]{
- 39 override def compare(c1:Integer, c2:Integer): Int = {
- 40 c2.compareTo(c1);
- 41 }
- 42 }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement