public List < Product > getSortedProducts ( ) { ArrayList < Product > result = new ArrayList <> ( pcm . getProducts ( ) ) ; Collections . sort ( result , new Comparator < Product > ( ) { @ Override public int compare ( Product o1 , Product o2 ) { Integer op1 = getProductPosition ( o1 ) ; Integer op2 = getProductPosition ( o2 ) ; return op1 . compareTo ( op2 ) ; } } ) ; return result ; }
Return the sorted products concordingly with metadata