按自定义非字母顺序排序数组

时间:2018-02-28 14:12:03

标签: php arrays sorting

我有一个数组,我需要按自定义顺序排序(非字母)。我怎么能这样做?

我当前的数组如下所示:

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
        )

)

我想使用groottelid值对其进行排序。像这样:

groot
middel
klein

这样做的好方法是什么?

不幸的是我无法在表格中添加新列,然后我可以对结果进行排序,因此必须在数组本身上完成。

0 个答案:

没有答案