A
A
Angelxalfa2015-09-19 23:36:14
PHP
Angelxalfa, 2015-09-19 23:36:14

Natural sorting of multidimensional array?

Good day!
I have an array containing streets => houses => apartments
Example

[улица1
  [1
    [10,2,3,6,]
  ]
  [3
    [5,9,2]
  ]
  [1a
     [2,6]
   ]
]

How to apply a natural sort to such an array? The difficulty is that houses and apartments can contain letters in addition to numbers, and only the second (houses) and third (apartments) array levels need to be sorted.
in the end it should be like this.
[улица1
  [1
    [2,3,6,10]
  ]
  [1a
     [2,6]
   ]
  [3
    [2,5,9]
  ]
]

Here is a piece of the original array
array(241) { ["Street1"]=> array(71) { [10]=> array(2) { [0]=> string(1) "1" [1]=> string( 1) "2" } [11]=> array(1) { [0]=> string(0) "" }.....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Optimus, 2015-09-19
@Angelxalfa

You have an error with the tree syntax.
If the arrays with houses are
$array[1], $array[2], $array[3], then loop through from and do sort($array[$i])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question