...

View Full Version : Ksort problem



icklechurch
11-04-2009, 10:32 AM
Hi,

I have the following array - how do I sort it so that it's in numerical key order? I tried ksort() but had no joy :(

[0]=>
array(4) {
["field_display_name"]=>
string(5) "title"

}
[7]=>
array(4) {
["field_display_name"]=>
string(13) "object_number"

}
[1]=>
array(4) {
["field_display_name"]=>
string(11) "description"
}
[2]=>
array(4) {
["field_display_name"]=>
string(19) "content.description"

}
[6]=>
array(4) {
["field_display_name"]=>
string(15) "content.subject"

}
[5]=>
array(4) {
["field_display_name"]=>
string(7) "creator"

}
[4]=>
array(4) {
["field_display_name"]=>
string(16) "production.place"

}
[3]=>
array(4) {
["field_display_name"]=>
string(21) "production.date.start"

}
}

Fumigator
11-04-2009, 05:28 PM
ksort() worked fine for me....



Original array
Array
(
[0] => Array
(
[field_display_name] => title
)

[7] => Array
(
[field_display_name] => object_number
)

[1] => Array
(
[field_display_name] => description
)

[2] => Array
(
[field_display_name] => content.description
)

[6] => Array
(
[field_display_name] => content.subject
)

[5] => Array
(
[field_display_name] => creator
)

[4] => Array
(
[field_display_name] => production.place
)

[3] => Array
(
[field_display_name] => production.date.start
)

)

Sorted array

Array
(
[0] => Array
(
[field_display_name] => title
)

[1] => Array
(
[field_display_name] => description
)

[2] => Array
(
[field_display_name] => content.description
)

[3] => Array
(
[field_display_name] => production.date.start
)

[4] => Array
(
[field_display_name] => production.place
)

[5] => Array
(
[field_display_name] => creator
)

[6] => Array
(
[field_display_name] => content.subject
)

[7] => Array
(
[field_display_name] => object_number
)

)


Maybe you could show the code you're using?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum