Sort the given string using character search | function to sort the given string without using any sorting technique ; to store the final sorted string ; for each character ' i ' ; if character ' i ' is present at a particular index then add character ' i ' to ' new _ str ' ; required final sorted string ; Driver program to test above
function sortString ( str , n ) { var new_str = " " ; for ( var i = ' ' . charCodeAt ( 0 ) ; i <= ' ' . charCodeAt ( 0 ) ; i ++ ) for ( var j = 0 ; j < n ; j ++ ) if ( str [ j ] . charCodeAt ( 0 ) == i ) new_str += str [ j ] ; return new_str ; } var str = " " ; var n = str . length ; document . write ( sortString ( str , n ) ) ;