Sort Array according to modulus of their values with their frequencies
Given an array arr containing N positive integers, sort them according to the increasing modulus of their values with their frequencies. Example: Input: arr[]={1, 1, 5, 3, 2, 3, 3, 3, 4, 5, 4, 5}Output: 2 4 4 1 1 5 5 5 3 3 3 3 Explanation:The elements are sorted in the following order:2 % frequency(2) = 2 % 1 = 04 % frequency(4) = 4 % 2 = 01 % freq