Kotlin sortBy on TreeMap
<p>What is the kotlin way of accomplisg this:</p>

<pre><code>public static TreeMap&lt;Integer, ArrayList&lt;HomeItem&gt;&gt; getHomeItemListsSeparatedByPageId(List&lt;HomeItem&gt; homeItemsList) {

        if (homeItemsList.size() == 0) {
            return new TreeMap&lt;&gt;();
        }

        TreeMap&lt;Integer, ArrayList&lt;HomeItem&gt;&gt; map = new TreeMap&lt;&gt;();

        for (HomeItem hl : homeItemsList) {
            if (map.get(hl.getVisiblePageId()) == null) {
                map.put(hl.getVisiblePageId(), new ArrayList&lt;&gt;());
            }
            map.get(hl.getVisiblePageId()).add(hl);
        }

        return map;
    }
</code></pre>

<p>I have tried to apply groupBy on my args list but it returns an HashMap.</p>

<p>EDIT: Basically, the original list is queried, and it is grouped by <code>visiblePageId</code>, and added to a treemap whose key is the id and the value are the items with that id</p>