using
System;
using
System.Collections.Generic;
public
class
GFG{
class
pair : IComparable<pair>
{
public
String first;
public
int
second;
public
pair(String first,
int
second)
{
this
.first = first;
this
.second = second;
}
public
int
CompareTo(pair o)
{
return
this
.first.CompareTo(o.first);
}
}
static
String []one
= {
""
,
"one "
,
"two "
,
"three "
,
"four "
,
"five "
,
"six "
,
"seven "
,
"eight "
,
"nine "
,
"ten "
,
"eleven "
,
"twelve "
,
"thirteen "
,
"fourteen "
,
"fifteen "
,
"sixteen "
,
"seventeen "
,
"eighteen "
,
"nineteen "
};
static
String []ten
= {
""
,
""
,
"twenty "
,
"thirty "
,
"forty "
,
"fifty "
,
"sixty "
,
"seventy "
,
"eighty "
,
"ninety "
};
static
String numToWords(
int
n, String s)
{
String str =
""
;
if
(n > 19)
str += ten[n / 10] + one[n % 10];
else
str += one[n];
if
(n>0)
str += s;
return
str;
}
static
String convertToWords(
int
n)
{
String Out =
""
;
Out += numToWords((n / 10000000),
"crore "
);
Out += numToWords(((n / 100000) % 100),
"lakh "
);
Out += numToWords(((n / 1000) % 100),
"thousand "
);
Out += numToWords(((n / 100) % 10),
"hundred "
);
if
(n > 100 && n % 100!=0)
Out +=
"and "
;
Out += numToWords((n % 100),
""
);
return
Out;
}
static
void
sortArr(
int
[]arr,
int
n)
{
List<pair> vp =
new
List<pair>();
for
(
int
i = 0; i < n; i++) {
vp.Add(
new
pair(
convertToWords(arr[i]), arr[i]));
}
vp.Sort();
for
(
int
i = 0; i < vp.Count; i++)
Console.Write(vp[i].second+
" "
);
}
public
static
void
Main(String[] args)
{
int
[]arr = { 12, 10, 102, 31, 15 };
int
n = arr.Length;
sortArr(arr, n);
}
}