1

I have an array that I need sorted in a custom order (non alphabetical). How can I do that?

My current array looks like this:

Array
(
    [0] => Array
        (
            [id] => 29
            [title] => Christien Quint  
            [introtext] => 
Boekhouding


            [fulltext] => 
            [ordering] => 8
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => christien-quint
            [state] => 1
            [item_id] => 29
            [groottelid] => groot
        )

    [1] => Array
        (
            [id] => 28
            [title] => Roel Methorst
            [introtext] => 
Algemeen directeur


            [fulltext] => 
            [ordering] => 9
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => roel-methorst
            [state] => 1
            [item_id] => 28
            [groottelid] => groot
        )

    [2] => Array
        (
            [id] => 30
            [title] => Johan De Troyer  
            [introtext] => 
Erkend adviseur Regio West-Vlaanderen


            [fulltext] => 
            [ordering] => 7
            [images] => {"image_intro":"images\/artikelen\/timber.jpg","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => johan-de-troyer
            [state] => 1
            [item_id] => 30
            [groottelid] => klein
        )

    [3] => Array
        (
            [id] => 31
            [title] => Tom Van Peteghem
            [introtext] => 
Erkend adviseur Regio Oost-Vlaanderen


            [fulltext] => 
            [ordering] => 6
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => tom-van-peteghem
            [state] => 1
            [item_id] => 31
            [groottelid] => klein
        )

    [4] => Array
        (
            [id] => 32
            [title] => Jean-Pierre Adams
            [introtext] => 
Erkend adviseur Regio Vlaams & Waals-Brabant


            [fulltext] => 
            [ordering] => 5
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => jean-pierre-adams
            [state] => 1
            [item_id] => 32
            [groottelid] => klein
        )

    [5] => Array
        (
            [id] => 33
            [title] => Michel Ennekens 
            [introtext] => 
Erkend adviseur Regio Antwerpen


            [fulltext] => 
            [ordering] => 4
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => michel-ennekens
            [state] => 1
            [item_id] => 33
            [groottelid] => klein
        )

    [6] => Array
        (
            [id] => 34
            [title] => Eef Schuurmans   
            [introtext] => 
Erkend adviseur Erkend adviseur


            [fulltext] => 
            [ordering] => 3
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => eef-schuurmans
            [state] => 1
            [item_id] => 34
            [groottelid] => klein
        )

    [7] => Array
        (
            [id] => 35
            [title] => Edwin Verheul
            [introtext] => 
Hoofduitvoerder Regio Oost & West-Vlaanderen


            [fulltext] => 
            [ordering] => 2
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => edwin-verheul
            [state] => 1
            [item_id] => 35
            [groottelid] => middel
        )

    [8] => Array
        (
            [id] => 36
            [title] => Jorn De Zaaijer
            [introtext] => 
Hoofduitvoerder Regio Antwerpen & Limburg


            [fulltext] => 
            [ordering] => 1
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => jorn-de-zaaijer
            [state] => 1
            [item_id] => 36
            [groottelid] => middel
        )

    [9] => Array
        (
            [id] => 37
            [title] => Remco Mijderwijk
            [introtext] => 
Hoofduitvoerder Regio Vlaams & Waals-Brabant


            [fulltext] => 
            [ordering] => 0
            [images] => {"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
            [alias] => remco-mijderwijk
            [state] => 1
            [item_id] => 37
            [groottelid] => middel
        )

)

I want to sort it using the groottelid value. Like this:

groot
middel
klein

What would be a good way to do this?

Unfortunately I can't add new columns in the table on which I can then order the result so it has to be done on the array itself.

twan
  • 2,017
  • 8
  • 22
  • 59

0 Answers0