What is the simplest way to implement this Linq query in Java?

I have C# code that takes values of dictionary, sorts them and turns into list (using Linq). I would like to know how to do the same thing in Java (prefer most simple way).

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Test
{
    class Test
    {
        static void Main() {
            Dictionary<string, string> wars = new Dictionary<string,string> () {
                {"WWI","1914-1918"}, {"WWII","1939-1945"}, {"Vietnam War","1955-1975"}
            };

            var query=(from item in wars orderby item.Value descending select item.Value).ToList();

            foreach (var i in query) {
                Console.WriteLine (i);
            }
        }
    }

You will have to store them as a LinkedHashMap and sort them yourself. There isn’t any super easy way to do this, that I know of off hand.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.