Php 如何根据值对索引数组进行排序';s键

Php 如何根据值对索引数组进行排序';s键,php,arrays,Php,Arrays,我有一个数组 "result": [ { "id": "38", "detailAddress": "Fhfd", "vendEmail": "test@hgh.fhh", "vendAddress": "Chff", "orderID": "", "invoiceNo": "CHVF", "vendName": "xhvx", "employeeToken":

我有一个数组

"result": [
    {
        "id": "38",
        "detailAddress": "Fhfd",
        "vendEmail": "test@hgh.fhh",
        "vendAddress": "Chff",
        "orderID": "",
        "invoiceNo": "CHVF",
        "vendName": "xhvx",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-11-01",
        "comments": "",
        "vendPhone": "12454698",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "John Snow"
    },
    {
        "id": "37",
        "detailAddress": "hahah",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "hahayayya",
        "orderID": "UAUAUJ",
        "invoiceNo": "NAJAIANNAN£×*",
        "vendName": "hahahah",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-22",
        "comments": "",
        "vendPhone": "9484848",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "6",
        "grand_total": "12.720",
        "tc": "Payment is due within 15 days.",
        "fullName": "John Snow"
    },
    {
        "id": "35",
        "detailAddress": "Chvf",
        "vendEmail": "xvbc@dgh.chh",
        "vendAddress": "Chhxvhc",
        "orderID": "DGGC",
        "invoiceNo": "DGGC",
        "vendName": "xhvc",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-24",
        "comments": "",
        "vendPhone": "458858255",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "2",
        "grand_total": "25.500",
        "tc": "Payment is due within 15 days.",
        "fullName": "John Snow"
    },
    {
        "id": "31",
        "detailAddress": "dhhd",
        "vendEmail": "dhhd@hdhd.com",
        "vendAddress": "dgdggdgd",
        "orderID": "YDUDHD",
        "invoiceNo": "6E6E6",
        "vendName": "ydydgd",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-06",
        "comments": "",
        "vendPhone": "46466484",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "30",
        "detailAddress": "hdhdhd\ndnjdjf\n",
        "vendEmail": "djhdhd@vdjd.com",
        "vendAddress": "dgdgdhdhd",
        "orderID": "637474",
        "invoiceNo": "367373",
        "vendName": "dhdhhd",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-06",
        "comments": "",
        "vendPhone": "64656588",
        "payment": "confirmed",
        "employee_payment": "1",
        "tax": "0",
        "grand_total": "80.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "29",
        "detailAddress": "jahab",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "uahahwb",
        "orderID": "ORDER123",
        "invoiceNo": "ORDER",
        "vendName": "bBabba",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-06",
        "comments": "",
        "vendPhone": "6464870",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "28",
        "detailAddress": "gulverg",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "nanajwn",
        "orderID": "SUBS",
        "invoiceNo": "DELE",
        "vendName": "Yar ",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-06",
        "comments": "",
        "vendPhone": "648484",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "27",
        "detailAddress": "hshah",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "bavwv",
        "orderID": "BSBSHEH",
        "invoiceNo": "HABAH",
        "vendName": "hhahah",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-06",
        "comments": "",
        "vendPhone": "948484",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "24",
        "detailAddress": "Gilbert",
        "vendEmail": "bilal@bilal.com",
        "vendAddress": "sggsgdgs",
        "orderID": "36UR7R",
        "invoiceNo": "7E7373",
        "vendName": "Bilal",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-05",
        "comments": "",
        "vendPhone": "464654",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "23",
        "detailAddress": "shhdhd",
        "vendEmail": "hdhd@hdjd.com",
        "vendAddress": "shhshdd",
        "orderID": "9696969",
        "invoiceNo": "99999",
        "vendName": "shdhd",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-10-05",
        "comments": "",
        "vendPhone": "986868",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000000",
        "tc": null,
        "fullName": "John Snow"
    },
    {
        "id": "1",
        "detailAddress": "Some Address",
        "vendEmail": "ali.zia.1991@gmail.com",
        "vendAddress": "johar",
        "orderID": "12345678",
        "invoiceNo": "ABC1234",
        "vendName": "Syed Ali Zia",
        "employeeToken": "597c7caeb22d9",
        "status": "1",
        "orderDate": "2017-09-21",
        "comments": "",
        "vendPhone": "221212",
        "payment": "confirmed",
        "employee_payment": "1",
        "tax": "5",
        "grand_total": "40",
        "tc": "Test T and Cs",
        "fullName": "John Snow"
    },
    {
        "id": "80",
        "detailAddress": "Office address Lala g ",
        "vendEmail": "adeel@plutopixel.com",
        "vendAddress": "Planet ",
        "orderID": "",
        "invoiceNo": "PDFQQ@",
        "vendName": "name john ",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-11-09",
        "comments": "",
        "vendPhone": "03311556688441",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "20",
        "grand_total": "120.000000",
        "tc": "Payment is due within 15 days. ",
        "fullName": "Admin"
    },
    {
        "id": "79",
        "detailAddress": "Office address Lala g ",
        "vendEmail": "adeel@plutopixel.com",
        "vendAddress": "Planet ",
        "orderID": "",
        "invoiceNo": "PDFQQ@",
        "vendName": "name john ",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-11-09",
        "comments": "",
        "vendPhone": "03311556688441",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "20",
        "grand_total": "120.000000",
        "tc": "Payment is due within 15 days. ",
        "fullName": "Admin"
    },
    {
        "id": "78",
        "detailAddress": "dgdyyd\ndhdhdh",
        "vendEmail": "ryfhhf@hdhd.com",
        "vendAddress": "djdjjddh",
        "orderID": "EHRHYD",
        "invoiceNo": "YDYDYD",
        "vendName": "dhhdhd",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-11-09",
        "comments": "",
        "vendPhone": "865665656",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "50.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "77",
        "detailAddress": "yshdhd",
        "vendEmail": "hxhchd@hdhd.com",
        "vendAddress": "dhdhhdhd",
        "orderID": "DYYDYD",
        "invoiceNo": "636363",
        "vendName": "dhhdhd",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-11-09",
        "comments": "",
        "vendPhone": "566565658",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "30.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "53",
        "detailAddress": "isuwu",
        "vendEmail": "iqra@bugdevstudios.com",
        "vendAddress": "jwjwjj",
        "orderID": "",
        "invoiceNo": "HAHH",
        "vendName": "bwbs",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-27",
        "comments": "",
        "vendPhone": "4616488484",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "3",
        "grand_total": "3.090",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "52",
        "detailAddress": "hsh",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "iwj1j1j1",
        "orderID": "JSHA",
        "invoiceNo": "123456",
        "vendName": "jshsbs",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-27",
        "comments": "",
        "vendPhone": "9419617884",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "6",
        "grand_total": "32.860",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "51",
        "detailAddress": "jshshwh",
        "vendEmail": "jajqj1@g.com",
        "vendAddress": "iqjwnwn",
        "orderID": "JSJSHH",
        "invoiceNo": "VRVV",
        "vendName": "jahab",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-27",
        "comments": "",
        "vendPhone": "979496669",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "6",
        "grand_total": "3.180",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "50",
        "detailAddress": "ywhwh",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "jqh1h1h",
        "orderID": "YQY1G",
        "invoiceNo": "TESTT",
        "vendName": "hsgag",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-27",
        "comments": "",
        "vendPhone": "3184040",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "2",
        "grand_total": "3.060",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "46",
        "detailAddress": "askari",
        "vendEmail": "safwan.ahmed@live.com",
        "vendAddress": "kajawjjw",
        "orderID": "ORDER",
        "invoiceNo": "DRAFT1",
        "vendName": "safwan",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-26",
        "comments": "",
        "vendPhone": "67648401",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "2",
        "grand_total": "5.100",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "44",
        "detailAddress": "6h",
        "vendEmail": "john@detail360.com",
        "vendAddress": "rctv",
        "orderID": "",
        "invoiceNo": "TVVFT",
        "vendName": "gvyv",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-25",
        "comments": "",
        "vendPhone": "5882505",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "50",
        "grand_total": "87.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "43",
        "detailAddress": "Dhdhhd",
        "vendEmail": "hHa@ckfk.com",
        "vendAddress": "Shahid",
        "orderID": "HDJDJDHD):72€\\$€]",
        "invoiceNo": "GDKDJDSHHSSHHS£:):?)",
        "vendName": "shshs\n",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "1998-03-08",
        "comments": "",
        "vendPhone": "4545",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "20",
        "grand_total": "6060.000000",
        "tc": null,
        "fullName": "Admin"
    },
    {
        "id": "42",
        "detailAddress": "susuus\njsjd",
        "vendEmail": "sbhshs@bd.com",
        "vendAddress": "shjs",
        "orderID": "SHDHDH",
        "invoiceNo": "3663E",
        "vendName": "shhdjd",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-18",
        "comments": "",
        "vendPhone": "466464",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "05",
        "grand_total": "210.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "41",
        "detailAddress": "dhdhd\ndjdjd",
        "vendEmail": "gxgxgd@jsjs.com",
        "vendAddress": "suusud",
        "orderID": "EHHEDDHSH",
        "invoiceNo": "736363",
        "vendName": "djjdj",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-21",
        "comments": "",
        "vendPhone": "46646565",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "30",
        "grand_total": "65.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "25",
        "detailAddress": "gulberg",
        "vendEmail": "safwan.ahmed6@gmail.com",
        "vendAddress": "johar town",
        "orderID": "1234SAF",
        "invoiceNo": "SAFWANTEST",
        "vendName": "safwab",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-06",
        "comments": "",
        "vendPhone": "94788787",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "25",
        "grand_total": "15.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "18",
        "detailAddress": "Test",
        "vendEmail": "a@a.com",
        "vendAddress": "Hdhshshsb",
        "orderID": "JUGGGY67",
        "invoiceNo": "JCGGY564",
        "vendName": "snjssj",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-05",
        "comments": "",
        "vendPhone": "54545454",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "35",
        "grand_total": "472.500000",
        "tc": "Test tc",
        "fullName": "Admin"
    },
    {
        "id": "17",
        "detailAddress": "Hahahaha Habib",
        "vendEmail": "bugdev.tester@gmail.com",
        "vendAddress": "Sjshsjsjehsh",
        "orderID": "ORD111",
        "invoiceNo": "JSJSHSHS",
        "vendName": "ali zia",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-10-05",
        "comments": "",
        "vendPhone": "1234567890",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "10",
        "grand_total": "13.200000",
        "tc": "Test terms",
        "fullName": "Admin"
    },
    {
        "id": "12",
        "detailAddress": "Some address",
        "vendEmail": "test@email.co",
        "vendAddress": "Test address",
        "orderID": "TEST1",
        "invoiceNo": "TEST1",
        "vendName": "some name",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-09-27",
        "comments": "",
        "vendPhone": "124536987",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "50",
        "grand_total": "225.000000",
        "tc": "Test terms",
        "fullName": "Admin"
    },
    {
        "id": "11",
        "detailAddress": "Address",
        "vendEmail": "test@test.com",
        "vendAddress": "Address test",
        "orderID": "ADM11",
        "invoiceNo": "ADM1",
        "vendName": "name",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-09-27",
        "comments": "",
        "vendPhone": "123546987",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "10",
        "grand_total": "16.500000",
        "tc": "Test",
        "fullName": "Admin"
    },
    {
        "id": "5",
        "detailAddress": "agag",
        "vendEmail": "vavaf@jd.com",
        "vendAddress": "vagavav",
        "orderID": "HAHAHS",
        "invoiceNo": "MABSHS",
        "vendName": "gahag",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-09-26",
        "comments": "",
        "vendPhone": "9797979",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "2.000",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    },
    {
        "id": "2",
        "detailAddress": "cyynbct yjvvvt",
        "vendEmail": "tanyaj@detail3sixty.com",
        "vendAddress": "cggggccgyuhvc",
        "orderID": "dt66fvj",
        "invoiceNo": "skiryuhghif",
        "vendName": "chy7cjj",
        "employeeToken": "5966136def9a6",
        "status": "1",
        "orderDate": "2017-09-30",
        "comments": "",
        "vendPhone": "8866658",
        "payment": "pending",
        "employee_payment": "0",
        "tax": "0",
        "grand_total": "258.0",
        "tc": "Payment is due within 15 days.",
        "fullName": "Admin"
    }
]

我想根据
id
对其进行排序。我尝试使用
USORT
,但它不起作用

这不是数组,这是JSON。@JayBlanchard这个问题是错误的。。。请用钥匙检查是否有分拣。他要求按价值排序。。。答案必须是array_multisort()@Nawin OP说,“value's key”,他还说,“我想根据id对它进行排序。”你可能是对的,但问题并不反映这一点。像这样试试,
var sort=result.sort(函数(a,b){返回a.id-b.id})这是一个使用排序数组的php脚本,它不是数组,而是JSON。@JayBlanchard这个问题是错误的。。。请用钥匙检查是否有分拣。他要求按价值排序。。。答案必须是array_multisort()@Nawin OP说,“value's key”,他还说,“我想根据id对它进行排序。”你可能是对的,但问题并不反映这一点。像这样试试,
var sort=result.sort(函数(a,b){返回a.id-b.id})这是一个使用排序数组的php脚本