Sorting in ascedning order
-83 -29 -12 4 5 17 17 32 100
Sorting in descending order
100 32 17 17 5 4 -12 -29 -83

Original Array:
Mike=>28
Peter=>35
Ben=>28
Joe=>18
Kelly=>28

Sort in ascending order for associative array by values
Joe=>18
Mike=>28
Ben=>28
Kelly=>28
Peter=>35

Sort in descending order for associative array by values
Peter=>35
Ben=>28
Mike=>28
Kelly=>28
Joe=>18


Sort in ascending order for associative array by keys
Ben=>28
Joe=>18
Kelly=>28
Mike=>28
Peter=>35

Peter=>35
Mike=>28
Kelly=>28
Joe=>18
Ben=>28

Sort in a speical way which may not work!!!
Sorted by age in ascending order. If the ages are the same, sort by names in ascending order.
Joe=>18
Ben=>28
Kelly=>28
Mike=>28
Peter=>35


Sorted by age in ascending order. If the ages are the same, sort by names in descending order.
Joe=>18
Kelly=>28
Mike=>28
Ben=>28
Peter=>35


Sort in ascending order using index array by values, which would lose all the key values
0=>18
1=>28
2=>28
3=>28
4=>35

Original Data:
NameAgeGender Grade
Mike22Male75
Jason18Male55
Jenny25Female95
Megan18Female85
Tom34Male75
Lilly21Female75
Alex18Male88
Amy18Female75
Sorted in ascending order by names
NameAgeGender Grade
Alex18Male88
Amy18Female75
Jason18Male55
Jenny25Female95
Lilly21Female75
Megan18Female85
Mike22Male75
Tom34Male75
Sorted in descending order by ages
NameAgeGender Grade
Tom34Male75
Jenny25Female95
Mike22Male75
Lilly21Female75
Megan18Female85
Jason18Male55
Amy18Female75
Alex18Male88
Sorted in ascending order by grades
NameAgeGender Grade
Jason18Male55
Amy18Female75
Lilly21Female75
Mike22Male75
Tom34Male75
Megan18Female85
Alex18Male88
Jenny25Female95
Sorted in ascending order by ages. If ages are the same, then sorted by grades in ascending oreder
NameAgeGender Grade
Jason18Male55
Amy18Female75
Megan18Female85
Alex18Male88
Lilly21Female75
Mike22Male75
Jenny25Female95
Tom34Male75
Sorted in ascending order by grade. If grades are the same, then sorted by gender in ascending oreder. If genders are the same, then sorted by age in ascending oreder.
NameAgeGender Grade
Jason18Male55
Amy18Female75
Lilly21Female75
Mike22Male75
Tom34Male75
Megan18Female85
Alex18Male88
Jenny25Female95
Sort 1D associative array using two attributes.
Sorted by age in descending order. If the ages are the same, sort by names in descending order.
4=>35
3=>28
2=>28
1=>28
0=>18
Sorted in ascending order by 2nd column. If the values of the 2nd column are the same, then sorted by 5th column in descending oreder.

NameAgeGender Grade
9190979497919798DEKU100
9590979497969396AIQP95
97901009792939293NXCF93
10093969894939390PYOL91
94939890941009598XGNB90
9494929996929697WAXS90
979590901001009991LWDU98
9795989191949391RIIU97
100959510090999495XRZC100
10096949698919094YKUR94
9196989191959391KCOS96
9497919699929791PGUO94
9297989399969997ENTR100
9497909792929595UGWA96
9398959098949092WJZO96
93989698949891100NPKN100
919810094939594100AZXL91
97989194919297100MOTX96
999998100991009898IXSF93
96100939396909196HZLL92
Sorted in ascending order by 2nd column. If the values of the 2nd column are the same, then sorted by 5th column in descending oreder. If the values of the 5th column are the same, then sorted by 9th column in descending oreder.
NameAgeGender Grade
9190979497919798DEKU100
9590979497969396AIQP95
97901009792939293NXCF93
94939890941009598XGNB90
10093969894939390PYOL91
9494929996929697WAXS90
979590901001009991LWDU98
9795989191949391RIIU97
100959510090999495XRZC100
10096949698919094YKUR94
9196989191959391KCOS96
9497919699929791PGUO94
9297989399969997ENTR100
9497909792929595UGWA96
9398959098949092WJZO96
93989698949891100NPKN100
919810094939594100AZXL91
97989194919297100MOTX96
999998100991009898IXSF93
96100939396909196HZLL92