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:
Name | Age | Gender |
Grade |
---|
Mike | 22 | Male | 75 |
Jason | 18 | Male | 55 |
Jenny | 25 | Female | 95 |
Megan | 18 | Female | 85 |
Tom | 34 | Male | 75 |
Lilly | 21 | Female | 75 |
Alex | 18 | Male | 88 |
Amy | 18 | Female | 75 |
Sorted in ascending order by names
Name | Age | Gender |
Grade |
---|
Alex | 18 | Male | 88 |
Amy | 18 | Female | 75 |
Jason | 18 | Male | 55 |
Jenny | 25 | Female | 95 |
Lilly | 21 | Female | 75 |
Megan | 18 | Female | 85 |
Mike | 22 | Male | 75 |
Tom | 34 | Male | 75 |
Sorted in descending order by ages
Name | Age | Gender |
Grade |
---|
Tom | 34 | Male | 75 |
Jenny | 25 | Female | 95 |
Mike | 22 | Male | 75 |
Lilly | 21 | Female | 75 |
Megan | 18 | Female | 85 |
Jason | 18 | Male | 55 |
Amy | 18 | Female | 75 |
Alex | 18 | Male | 88 |
Sorted in ascending order by grades
Name | Age | Gender |
Grade |
---|
Jason | 18 | Male | 55 |
Amy | 18 | Female | 75 |
Lilly | 21 | Female | 75 |
Mike | 22 | Male | 75 |
Tom | 34 | Male | 75 |
Megan | 18 | Female | 85 |
Alex | 18 | Male | 88 |
Jenny | 25 | Female | 95 |
Sorted in ascending order by ages.
If ages are the same, then sorted by grades in ascending oreder
Name | Age | Gender |
Grade |
---|
Jason | 18 | Male | 55 |
Amy | 18 | Female | 75 |
Megan | 18 | Female | 85 |
Alex | 18 | Male | 88 |
Lilly | 21 | Female | 75 |
Mike | 22 | Male | 75 |
Jenny | 25 | Female | 95 |
Tom | 34 | Male | 75 |
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.
Name | Age | Gender |
Grade |
---|
Jason | 18 | Male | 55 |
Amy | 18 | Female | 75 |
Lilly | 21 | Female | 75 |
Mike | 22 | Male | 75 |
Tom | 34 | Male | 75 |
Megan | 18 | Female | 85 |
Alex | 18 | Male | 88 |
Jenny | 25 | Female | 95 |
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.
Name | Age | Gender |
Grade |
---|
91 | 90 | 97 | 94 | 97 | 91 | 97 | 98 | DEKU | 100 |
95 | 90 | 97 | 94 | 97 | 96 | 93 | 96 | AIQP | 95 |
97 | 90 | 100 | 97 | 92 | 93 | 92 | 93 | NXCF | 93 |
100 | 93 | 96 | 98 | 94 | 93 | 93 | 90 | PYOL | 91 |
94 | 93 | 98 | 90 | 94 | 100 | 95 | 98 | XGNB | 90 |
94 | 94 | 92 | 99 | 96 | 92 | 96 | 97 | WAXS | 90 |
97 | 95 | 90 | 90 | 100 | 100 | 99 | 91 | LWDU | 98 |
97 | 95 | 98 | 91 | 91 | 94 | 93 | 91 | RIIU | 97 |
100 | 95 | 95 | 100 | 90 | 99 | 94 | 95 | XRZC | 100 |
100 | 96 | 94 | 96 | 98 | 91 | 90 | 94 | YKUR | 94 |
91 | 96 | 98 | 91 | 91 | 95 | 93 | 91 | KCOS | 96 |
94 | 97 | 91 | 96 | 99 | 92 | 97 | 91 | PGUO | 94 |
92 | 97 | 98 | 93 | 99 | 96 | 99 | 97 | ENTR | 100 |
94 | 97 | 90 | 97 | 92 | 92 | 95 | 95 | UGWA | 96 |
93 | 98 | 95 | 90 | 98 | 94 | 90 | 92 | WJZO | 96 |
93 | 98 | 96 | 98 | 94 | 98 | 91 | 100 | NPKN | 100 |
91 | 98 | 100 | 94 | 93 | 95 | 94 | 100 | AZXL | 91 |
97 | 98 | 91 | 94 | 91 | 92 | 97 | 100 | MOTX | 96 |
99 | 99 | 98 | 100 | 99 | 100 | 98 | 98 | IXSF | 93 |
96 | 100 | 93 | 93 | 96 | 90 | 91 | 96 | HZLL | 92 |
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.
Name | Age | Gender |
Grade |
---|
91 | 90 | 97 | 94 | 97 | 91 | 97 | 98 | DEKU | 100 |
95 | 90 | 97 | 94 | 97 | 96 | 93 | 96 | AIQP | 95 |
97 | 90 | 100 | 97 | 92 | 93 | 92 | 93 | NXCF | 93 |
94 | 93 | 98 | 90 | 94 | 100 | 95 | 98 | XGNB | 90 |
100 | 93 | 96 | 98 | 94 | 93 | 93 | 90 | PYOL | 91 |
94 | 94 | 92 | 99 | 96 | 92 | 96 | 97 | WAXS | 90 |
97 | 95 | 90 | 90 | 100 | 100 | 99 | 91 | LWDU | 98 |
97 | 95 | 98 | 91 | 91 | 94 | 93 | 91 | RIIU | 97 |
100 | 95 | 95 | 100 | 90 | 99 | 94 | 95 | XRZC | 100 |
100 | 96 | 94 | 96 | 98 | 91 | 90 | 94 | YKUR | 94 |
91 | 96 | 98 | 91 | 91 | 95 | 93 | 91 | KCOS | 96 |
94 | 97 | 91 | 96 | 99 | 92 | 97 | 91 | PGUO | 94 |
92 | 97 | 98 | 93 | 99 | 96 | 99 | 97 | ENTR | 100 |
94 | 97 | 90 | 97 | 92 | 92 | 95 | 95 | UGWA | 96 |
93 | 98 | 95 | 90 | 98 | 94 | 90 | 92 | WJZO | 96 |
93 | 98 | 96 | 98 | 94 | 98 | 91 | 100 | NPKN | 100 |
91 | 98 | 100 | 94 | 93 | 95 | 94 | 100 | AZXL | 91 |
97 | 98 | 91 | 94 | 91 | 92 | 97 | 100 | MOTX | 96 |
99 | 99 | 98 | 100 | 99 | 100 | 98 | 98 | IXSF | 93 |
96 | 100 | 93 | 93 | 96 | 90 | 91 | 96 | HZLL | 92 |