Reorder the position of the words in alphabetical order | C # implementation of the approach ; Function to print the ordering of words ; Creating list of words and assigning them index numbers ; Sort the list of words lexicographically ; Print the ordering ; Driver Code
using System ; using System . Collections . Generic ; class GFG { static void reArrange ( String [ ] words , int n ) { Dictionary < String , int > freq = new Dictionary < String , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { freq . Add ( words [ i ] , ( i + 1 ) ) ; } Array . Sort ( words ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( freq [ words [ i ] ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { String [ ] words = { " live " , " place " , " travel " , " word " , " sky " } ; int n = words . Length ; reArrange ( words , n ) ; } }