if two elements have the same number of factors then sort them in increasing order of their index in the input array
if ( e1 . no_of_fact == e2 . no_of_fact ) return e1 . index < e2 . index ? - 1 : 1 ;