See this example.
<script> const s_word = '58 45dr-P'; const rev = [...s_word] .sort() // sort the word (punctuations first, followed by numbers, uppercase followed by lowercase alphabets .reverse() // reverse the sort order .join(''); // join the string (remove the commas) document.writeln(rev); // Output: rdP8554- </script>