Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static <T> void sortWithIndexesComparator(final List<T> list, final Comparator<Integer> comparator) {
        Collections.sort(list, new Comparator<T>() {
            @Override
            public int compare(T lhs, T rhs) {
                return comparator.compare(list.indexOf(lhs), list.indexOf(rhs));
            }
        });
    }
}