Продукт с полями (id, ProductName, CategoryName и т. д.). После создания массива продуктов и заполнения его такими значениями, как
Код: Выделить всё
ArrayList products = new ArrayList(Arrays.asList(
new DefaultProduct(1, "Hardwood Oak Suffolk Internal Door", "Doors", 109.99),
new DefaultProduct(2, "Oregon Cottage Interior Oak Door", "Doors", 179.99),
new DefaultProduct(3, "Oregon Cottage Horizontal Interior White Oak Door", "Doors", 189.99),
Код: Выделить всё
Collections.sort(products, new CustomProductComparator());
Код: Выделить всё
The method sort(List, Comparator
Источник: [url]https://stackoverflow.com/questions/78143013/method-sortlistt-comparator-super-t-in-the-type-collections-is-not-appli[/url]