/*
 * Aeronica's mxTune MOD
 * Copyright 2019, Paul Boese a.k.a. Aeronica
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package net.aeronica.mods.mxtune.gui.mml;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
import net.aeronica.mods.mxtune.managers.records.PlayList;
import net.aeronica.mods.mxtune.managers.records.Song;
import net.aeronica.mods.mxtune.managers.records.SongProxy;

import java.util.Comparator;

public final class SortHelper
{
    private SortHelper() { /* NOP */ }

    public static final Ordering<PlayList> PLAYLIST_ORDERING = Ordering.from(new PlaylistComparator());
    public static final Ordering<SongProxy> SONG_PROXY_ORDERING = Ordering.from(new SongProxyComparator());
    public static final Ordering<Song> SONG_ORDERING = Ordering.from(new SongComparator());

    static class PlaylistComparator implements Comparator<PlayList>
    {
        @Override
        public int compare(PlayList o1, PlayList o2)
        {
            return ComparisonChain.start().compare(o1.getName(), o2.getName()).result();
        }
    }

    static class SongProxyComparator implements Comparator<SongProxy>
    {
        @Override
        public int compare(SongProxy o1, SongProxy o2)
        {
            return ComparisonChain.start().compare(o1.getTitle(), o2.getTitle()).result();
        }
    }

    static class SongComparator implements Comparator<Song>
    {
        @Override
        public int compare(Song o1, Song o2)
        {
            return ComparisonChain.start().compare(o1.getTitle(), o2.getTitle()).result();
        }
    }
}

@@ -956,16 +956,55 @@
 ngProxy;
+%0Aimport net.minecraft.util.StringUtils;
 %0A%0Aimport
@@ -1025,16 +1025,41 @@
 parator;
+%0Aimport java.util.Locale;
 %0A%0Apublic
@@ -1631,24 +1631,34 @@
 t().compare(
+stripCase(
 o1.getName()
@@ -1657,18 +1657,29 @@
 etName()
+)
 , 
+stripCase(
 o2.getNa
@@ -1679,24 +1679,25 @@
 2.getName())
+)
 .result();%0A 
@@ -1914,32 +1914,42 @@
 start().compare(
+stripCase(
 o1.getTitle(), o
@@ -1937,34 +1937,45 @@
 se(o1.getTitle()
+)
 , 
+stripCase(
 o2.getTitle()).r
@@ -1964,32 +1964,33 @@
 e(o2.getTitle())
+)
 .result();%0A     
@@ -2191,16 +2191,26 @@
 compare(
+stripCase(
 o1.getTi
@@ -2214,18 +2214,29 @@
 tTitle()
+)
 , 
+stripCase(
 o2.getTi
@@ -2241,16 +2241,17 @@
 Title())
+)
 .result(
@@ -2268,11 +2268,144 @@
  %7D%0A    %7D
+%0A%0A    private static String stripCase(String s)%0A    %7B%0A        return StringUtils.stripControlCodes(s).toLowerCase(Locale.ROOT);%0A    %7D
 %0A%7D%0A

Improve sorting.