"use strict";(self.webpackChunkdami=self.webpackChunkdami||[]).push([[4591],{84591:(e,a,t)=>{t.r(a),t.d(a,{default:()=>n,sliceData:()=>i});var r=t(31263);async function i({id:e,data:a}){let t=null;if("table"===a.dataSource)t=this.engine.referenceData.table;else if("variable"===a.dataSource){const{variables:e}=this.engine.referenceData;if(!(0,r.aX)(e,a.varSourceName))throw new Error(`Cant find "${a.varSourceName}" variable`);t=e[a.varSourceName]}if(!Array.isArray(t)){throw new Error(`Can't sort data with "${null===t?"null":typeof t}" data type`)}const i=({itemA:e,itemB:a,order:t="asc"})=>{let r=0;return e>a?r=1:e<a&&(r=-1),"desc"===t?-1*r:r},n=t.sort(((e,t)=>{let r=0;return a.sortByProperty?a.itemProperties.forEach((({name:a,order:n})=>{r=i({order:n,itemA:e[a]??e,itemB:t[a]??t})})):r=i({itemA:e,itemB:t}),r}));return a.assignVariable&&this.setVariable(a.variableName,n),a.saveData&&this.addDataToColumn(a.dataColumn,n),{data:n,nextBlockId:this.getBlockConnections(e)}}const n=i}}]);