using System.Collections.Generic;
public static List<List<int>> GeneratePermutations()
List<int> data = [0,2,5];
var max = data.Count - 1;
List<List<int>> list = [];
for (int i = max; i >= 0; i--)
for (int j = max; j >= 0; j--)
list.Add([data[i],data[j],5,5]);
for (int i = max; i >= 0; i--)
for (int j = max; j >= 0; j--)
for (int k = max; k >= 0; k--)
list.Add([data[i],data[j],data[k],5]);
for (int i = max; i >= 0; i--)
for (int j = max; j >= 0; j--)
for (int k = max; k >= 0; k--)
list.Add([data[i],data[j],5,data[k]]);
return list.Distinct(new ListComparer()).Reverse().ToList();
public static void Main()
var list = new List<Test>{
new Test {a= 5,b= 5,c= 5,d= 5},
new Test {a= 5,b= 0,c= 5,d= 5},
new Test {a= 5,b= 5,c= 0,d= 5},
new Test {a= 5,b= 5,c= 5,d= 0},
new Test {a= 5,b= 2,c= 5,d= 2},
new Test {a= 2,b= 5,c= 2,d= 5},
new Test {a= 2,b= 0,c= 5,d= 2},
new Test {a= 0,b= 5,c= 2,d= 0},
new Test {a= 0,b= 2,c= 2,d= 5},
new Test {a= 0,b= 0,c= 0,d= 5},
new Test {a= 5,b= 2,c= 0,d= 2},
new Test {a= 5,b= 0,c= 2,d= 0}
var compare = GeneratePermutations();
foreach(var data in compare.AsQueryable().Reverse().ToList()) {
Console.WriteLine($"[{data[0]},{data[1]},{data[2]},{data[3]}]");
var newData = list.OrderByDescending(data => compare.FindIndex(c => c[0] == data.a && c[1] == data.b && c[2] == data.c && c[3] == data.d));
foreach(var data in newData) {
Console.WriteLine($"a = {data.a}, b = {data.b}, c = {data.c}, d = {data.d}, index = {compare.FindIndex(c => c[0] == data.a && c[1] == data.b && c[2] == data.c && c[3] == data.d)}");
public class ListComparer : IEqualityComparer<List<int>>
public bool Equals(List<int> x, List<int> y)
if (x.Count != y.Count())
for (int i = 0; i < x.Count; i++)
public int GetHashCode(List<int> obj)
foreach (var item in obj)
hash = hash * 23 + item.GetHashCode();