如何对子数组具有不同元素数的多维数组进行排序

时间:2019-06-14 12:48:28

标签: php codeigniter

我有以下数组-

数组 (     [0] =>数组         (             [student_id] => 1             [姓] => kopolovits             [名字] => arie             [已批准的小时数] => 2             [Rate Doe] => 2             [创建] => 2018-08-16 19:58:58             [状态] =>有效             [provider1] =>约瑟夫·贾拉斯             [approved_hour1] => 1             [provider2] =>约瑟夫·贾拉斯             [approved_hour2] => 1         )

[1] => Array
    (
        [student_id] => 2
        [Lastname] => Deep
        [Firstname] => Jonny
        [Approved Hrs] => 35
        [Rate Doe] => 200
        [Created] => 2018-09-07 13:40:49
        [Status] => active
        [provider1] => Sanjay Samanta
        [approved_hour1] => 
        [provider2] => Yosef Jalas
        [approved_hour2] => 5
        [provider3] => Yosef Jalas
        [approved_hour3] => 10
        [provider4] => Diptesh Ghosh
        [approved_hour4] => 15
    )

[2] => Array
    (
        [student_id] => 3
        [Lastname] => Dave
        [Firstname] => Smith
        [Approved Hrs] => 36
        [Rate Doe] => 100
        [Created] => 2018-09-07 13:43:09
        [Status] => active
        [provider1] => Sanjay Samanta
        [approved_hour1] => 16
        [provider2] => Diptesh Ghosh
        [approved_hour2] => 4
    )

[3] => Array
    (
        [student_id] => 4
        [Lastname] => Beller
        [Firstname] => Yaakov
        [Approved Hrs] => 15
        [Rate Doe] => 50
        [Created] => 2018-10-02 14:03:23
        [Status] => active
        [provider1] => Ryan Taylor
        [approved_hour1] => 8
        [provider2] => leib kop
        [approved_hour2] => 7
    )

[4] => Array
    (
        [student_id] => 5
        [Lastname] => Mondal
        [Firstname] => Sourav
        [Approved Hrs] => 30
        [Rate Doe] => 75
        [Created] => 2018-11-23 11:00:55
        [Status] => active
        [provider1] => Naba Sheet
        [approved_hour1] => 
        [provider2] => James Richard
        [approved_hour2] => 1
        [provider3] => Ryan Taylor
        [approved_hour3] => 
    )

[5] => Array
    (
        [student_id] => 6
        [Lastname] => Paul
        [Firstname] => Sandipta
        [Approved Hrs] => 12
        [Rate Doe] => 50
        [Created] => 2018-11-23 11:07:29
        [Status] => active
        [provider1] => Naba Sheet
        [approved_hour1] => 1
        [provider2] => Dipta Sarkar
        [approved_hour2] => 7
        [provider3] => Sandipta Paul
        [approved_hour3] => 1
        [provider4] => Diptesh Ghosh
        [approved_hour4] => 2
        [provider5] => Sukh Deb
        [approved_hour5] => 1
        [provider6] => Ryan Taylor
        [approved_hour6] => 
    )

[6] => Array
    (
        [student_id] => 7
        [Lastname] => Paul
        [Firstname] => Sandipta
        [Approved Hrs] => 12
        [Rate Doe] => 50
        [Created] => 2018-11-26 06:28:14
        [Status] => active
        [provider1] => Ryan Taylor
        [approved_hour1] => 
        [provider2] => James Richard
        [approved_hour2] => 2
    )

[7] => Array
    (
        [student_id] => 8
        [Lastname] => kopolovits
        [Firstname] => arietest
        [Approved Hrs] => 2
        [Rate Doe] => 500
        [Created] => 2018-12-04 06:25:01
        [Status] => active
        [provider1] => leib kop
        [approved_hour1] => 2
    )

[8] => Array
    (
        [student_id] => 9
        [Lastname] => Kid
        [Firstname] => Funny
        [Approved Hrs] => 12
        [Rate Doe] => 130
        [Created] => 2018-12-11 18:27:59
        [Status] => active
        [provider1] => samuel TestMe
        [approved_hour1] => 7
        [provider2] => Shmuley TestMe
        [approved_hour2] => 5
    )

[9] => Array
    (
        [student_id] => 10
        [Lastname] => funny
        [Firstname] => not very
        [Approved Hrs] => 7
        [Rate Doe] => 130
        [Created] => 2018-12-11 19:06:30
        [Status] => active
        [provider1] => samuel TestMe
        [approved_hour1] => 7
    )

在这里,子数组的索引5具有最高的元素,因此我希望它在顶部,然后以相同的顺序休息。

我正在尝试使用usort和array_multisort。

我期望最终数组为-

数组 (     [0] =>数组         (             [student_id] => 6             [姓] =>保罗             [名字] => Sandipta             [已批准的小时数] => 12             [Rate Doe] => 50             [创建] => 2018-11-23 11:07:29             [状态] =>有效             [provider1] => Naba工作表             [approved_hour1] => 1             [provider2] => Dipta Sarkar             [approved_hour2] => 7             [provider3] => Sandipta Paul             [approved_hour3] => 1             [provider4] => Diptesh Ghosh             [approved_hour4] => 2             [provider5] => Sukh Deb             [approved_hour5] => 1             [provider6] =>瑞安·泰勒(Ryan Taylor)             [approved_hour6] =>
        )

[1] => Array
    (
        [student_id] => 2
        [Lastname] => Deep
        [Firstname] => Jonny
        [Approved Hrs] => 35
        [Rate Doe] => 200
        [Created] => 2018-09-07 13:40:49
        [Status] => active
        [provider1] => Sanjay Samanta
        [approved_hour1] => 
        [provider2] => Yosef Jalas
        [approved_hour2] => 5
        [provider3] => Yosef Jalas
        [approved_hour3] => 10
        [provider4] => Diptesh Ghosh
        [approved_hour4] => 15
    )

[2] => Array
    (

        [student_id] => 5
        [Lastname] => Mondal
        [Firstname] => Sourav
        [Approved Hrs] => 30
        [Rate Doe] => 75
        [Created] => 2018-11-23 11:00:55
        [Status] => active
        [provider1] => Naba Sheet
        [approved_hour1] => 
        [provider2] => James Richard
        [approved_hour2] => 1
        [provider3] => Ryan Taylor
        [approved_hour3] => 
    )

[3] => Array
    (
        [student_id] => 4
        [Lastname] => Beller
        [Firstname] => Yaakov
        [Approved Hrs] => 15
        [Rate Doe] => 50
        [Created] => 2018-10-02 14:03:23
        [Status] => active
        [provider1] => Ryan Taylor
        [approved_hour1] => 8
        [provider2] => leib kop
        [approved_hour2] => 7
    )

[4] => Array
    (
        [student_id] => 3
        [Lastname] => Dave
        [Firstname] => Smith
        [Approved Hrs] => 36
        [Rate Doe] => 100
        [Created] => 2018-09-07 13:43:09
        [Status] => active
        [provider1] => Sanjay Samanta
        [approved_hour1] => 16
        [provider2] => Diptesh Ghosh
        [approved_hour2] => 4
    )

[5] => Array
    (
        [student_id] => 1
        [Lastname] => kopolovits
        [Firstname] => arie
        [Approved Hrs] => 2
        [Rate Doe] => 2
        [Created] => 2018-08-16 19:58:58
        [Status] => active
        [provider1] => Yosef Jalas
        [approved_hour1] => 1
        [provider2] => Yosef Jalas
        [approved_hour2] => 1
    )

[6] => Array
    (
        [student_id] => 7
        [Lastname] => Paul
        [Firstname] => Sandipta
        [Approved Hrs] => 12
        [Rate Doe] => 50
        [Created] => 2018-11-26 06:28:14
        [Status] => active
        [provider1] => Ryan Taylor
        [approved_hour1] => 
        [provider2] => James Richard
        [approved_hour2] => 2
    )

[7] => Array
    (
        [student_id] => 9
        [Lastname] => Kid
        [Firstname] => Funny
        [Approved Hrs] => 12
        [Rate Doe] => 130
        [Created] => 2018-12-11 18:27:59
        [Status] => active
        [provider1] => samuel TestMe
        [approved_hour1] => 7
        [provider2] => Shmuley TestMe
        [approved_hour2] => 5
    )

[8] => Array
    (
        [student_id] => 8
        [Lastname] => kopolovits
        [Firstname] => arietest
        [Approved Hrs] => 2
        [Rate Doe] => 500
        [Created] => 2018-12-04 06:25:01
        [Status] => active
        [provider1] => leib kop
        [approved_hour1] => 2
    )

[9] => Array
    (
        [student_id] => 10
        [Lastname] => funny
        [Firstname] => not very
        [Approved Hrs] => 7
        [Rate Doe] => 130
        [Created] => 2018-12-11 19:06:30
        [Status] => active
        [provider1] => samuel TestMe
        [approved_hour1] => 7
    )

0 个答案:

没有答案