Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting Jsonpath排序数组_Sorting_Soapui_Jsonpath - Fatal编程技术网

Sorting Jsonpath排序数组

Sorting Jsonpath排序数组,sorting,soapui,jsonpath,Sorting,Soapui,Jsonpath,请您帮我对使用$…balanceChange获得的数组进行排序。这只是回应的一小部分 我需要它在SoapUI中进行断言 { "id": 182, "name": "49899 Consol Sick w S&S Pattern", "eventDefinition": { "id": 111, "name": "49899 Consol Sick w S&S Pattern", "shortNa

请您帮我对使用$…balanceChange获得的数组进行排序。这只是回应的一小部分

我需要它在SoapUI中进行断言

{ "id": 182, "name": "49899 Consol Sick w S&S Pattern", "eventDefinition": { "id": 111, "name": "49899 Consol Sick w S&S Pattern", "shortName": null, "displayName": "49899 Consol Sick w S&S Pattern", "active": true, "group": null, "lowerThresholdAmount": 0, "upperThresholdAmount": 0, "lowerThresholdDayAmount": null, "upperThresholdDayAmount": null, "amountUnit": null, "exceptionType": null, "comment": null, "paycode": null, "paycodeAmountType": null, "usedType": null, "punchType": null, "type": {"name": "pattern"}, "extendedData": null, "dayBased": false }, "policyDefinition": { "id": 404, "name": "49899 Consolidated Sick w S&S plc467381724319" }, "ruleDefinition": { "id": 604, "name": "WR467381724319" }, "pointTransaction": { "id": 313, "name": "Attendance Points 1", "employeeId": 385, "balanceChange": 5, "typeCategory": "POINT", "applyDate": "2016-04-28T00:00:00" }, "type": {"name": "pattern"}, "employeeId": 385, "applyDate": "2016-04-28", "eventTime": "00:00:00", "amount": null, "dayAmount": null, "updatedByUserId": 12, "isSystem": true } { “id”:182, “名称”:“49899控制台病态w S&S模式”, “事件定义”:{ “id”:111, “名称”:“49899控制台病态w S&S模式”, “shortName”:空, “显示名称”:“49899控制台带S&S模式”, “主动”:正确, “组”:空, “lowerThresholdAmount”:0, “upperThresholdAmount”:0, “lowerThresholdDayAmount”:空, “upperThresholdDayAmount”:空, “amountUnit”:空, “exceptionType”:空, “注释”:空, “paycode”:空, “paycodeAmountType”:空, “usedType”:空, “punchType”:空, “类型”:{“名称”:“模式”}, “extendedData”:空, “基于日期”:错误 }, “保单定义”:{ “id”:404, “名称”:“49899合并病假w S&S plc467381724319” }, “规则定义”:{ “id”:604, “名称”:“WR467381724319” }, “点事务”:{ “id”:313, “姓名”:“考勤点1”, “雇员ID”:385, “平衡变化”:5, “类型类别”:“点”, “applyDate”:“2016-04-28:00:00” }, “类型”:{“名称”:“模式”}, “雇员ID”:385, “applyDate”:“2016-04-28”, “事件时间”:“00:00:00”, “金额”:空, “dayAmount”:空, “updatedByUserId”:12, “isSystem”:正确 } 尝试使用lib

或者只是最简单的(例如plunker)


您希望如何对其排序(Id、名称或对象)?你能再解释一下吗?当它执行$…balanceChange时,我得到了[9.0,8.0,9.0,8.0,8.0,6.0,5.0]。但有时这个序列是变化的,我可以得到[8.0,9.0,9.0,8.0,8.0,8.0,6.0,5.0]。我需要按BalanceChanges对这个数组进行排序,所以,最简单的方法是使用下划线。请看答案,它可能对您有帮助,如果没有,我将尝试重写代码,请告诉我您展示的示例不包含任何值,如9.0、8.0等。OP指定他使用的是SoapUI,它没有JS解释器。遗憾的是,这个答案不尊重问题给出的boudary
   var arr  = [
  { 
  "id": 182,
  "name": "49899 Consol Sick w S&S Pattern"
},
{ 
  "id": 183,
  "name": "49900 Consol Sick w S&S Pattern"
},{ 
  "id": 184,
  "name": "49901 Consol Sick w S&S Pattern"
},{ 
  "id": 185,
  "name": "49902 Consol Sick w S&S Pattern"
},{ 
  "id": 186,
  "name": "49903 Consol Sick w S&S Pattern"
},]


console.log(_.sortBy(arr, 'id'))
var data = [9.0, 8.0, 9.0, 8.0, 8.0, 8.0, 6.0, 5.0]
console.log(data.sort());