sorting question
| From: | Ed dot Lazor at AtFantasy dot com | Date: | Tue, 18 Nov 2003 23:25:02 +0000 |
| Subject: | sorting question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-170196@lists.php.net to get a copy of this message | ||
I used PHP to combine several MySQL queries into a single array and now I'm trying to sort the
results by one of the named columns. Is there an easy way to do this? asort didn't seem to do
the trick, but maybe I'm not using it correctly.
Here's the commands:
asort($T);
reset($T);
foreach($T as $key => $value)
foreach ($value as $key2 => $value2)
print "$key) $key2 = $value2<br>";
Here's the output... See how the entries aren't sorted by the date? That's what
I'm trying to accomplish.
0) Date = 2003-11-11
0) Type = Adj.
0) ID = 31
0) OrderNum = 31
0) Qty = 1
1) Date = 2003-11-04
1) Type = PO
1) ID = 34
1) OrderNum = 107
1) Status = C
1) Qty = 1008
2) Date = 2003-11-05
2) Type = DO
2) ID = 218
2) OrderNum = 178
2) Status = C
2) Qty = 6
3) Date = 2003-11-05
3) Type = DO
3) ID = 222
3) OrderNum = 180
3) Status = C
3) Qty = 6
6) Date = 2003-11-11
6) Type = DO
6) ID = 261
6) OrderNum = 261
6) Status = O
6) Qty = 4
4) Date = 2003-11-12
4) Type = DO
4) ID = 223
4) OrderNum = 223
4) Status = O
4) Qty = 6
7) Date = 2003-11-12
7) Type = DO
7) ID = 271
7) OrderNum = 271
7) Status = O
7) Qty = 5
9) Date = 2003-11-12
9) Type = DO
9) ID = 299
9) OrderNum = 299
9) Status = O
9) Qty = 12
10) Date = 2003-11-12
10) Type = DO
10) ID = 314
10) OrderNum = 314
10) Status = O
10) Qty = 3
11) Date = 2003-11-13
11) Type = DO
11) ID = 315
11) OrderNum = 315
11) Status = O
11) Qty = 12
12) Date = 2003-11-13
12) Type = DO
12) ID = 325
12) OrderNum = 325
12) Status = O
12) Qty = 12
5) Date = 2003-11-14
5) Type = DO
5) ID = 252
5) OrderNum = 252
5) Status = O
5) Qty = 18
8) Date = 2003-11-14
8) Type = DO
8) ID = 291
8) OrderNum = 291
8) Status = O
8) Qty = 12
13) Date = 2003-11-15
13) Type = DO
13) ID = 364
13) OrderNum = 364
13) Status = C
13) Qty = 18
15) Date = 2003-11-15
15) Type = DO
15) ID = 381
15) OrderNum = 381
15) Status = C
15) Qty = 12
14) Date = 2003-11-18
14) Type = DO
14) ID = 374
14) OrderNum = 374
14) Status = O
14) Qty = 6
16) Date = 2003-11-05
16) Type = DO
16) ID = 218
16) OrderNum = 178
16) Status = C
16) CrossReference = Y
16) Qty = 6
17) Date = 2003-11-05
17) Type = DO
17) ID = 222
17) OrderNum = 180
17) Status = C
17) CrossReference = Y
17) Qty = 6
18) Date = 2003-11-15
18) Type = DO
18) ID = 364
18) OrderNum = 364
18) Status = C
18) CrossReference = Y
18) Qty = 18
19) Date = 2003-11-15
19) Type = DO
19) ID = 381
19) OrderNum = 381
19) Status = C
19) CrossReference = Y
19) Qty = 12
Thanks in advance for any information you have to help.
-Ed