Sorting without comparison of elements | Represents node of a doubly linked list ; Count of elements in given range ; Count frequencies of all elements ; Traverse through range . For every element , print it its count times . ; Driver Code
function sortArr ( arr , n , min , max ) { let m = max - min + 1 ; let c = new Array ( m ) ; c . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { c [ arr [ i ] - min ] ++ ; } for ( let i = 0 ; i < m ; i ++ ) { for ( let j = 0 ; j < c [ i ] ; j ++ ) { document . write ( ( i + min ) + " " ) ; } } } let arr = [ 10 , 10 , 1 , 4 , 4 , 100 , 0 ] ; let min = 0 , max = 100 ; let n = arr . length ; sortArr ( arr , n , min , max ) ;