Sort foreach Data

Certified Senior Developer

Can anyone please hep me in this?

I want to sort below mentioned data. I was trying to sort data using queryentity and it worked. But I have to use rule input ri!employee(Type: Data Type). Please assist. 

Need to sort data by these fields:

sort: {
a!sortInfo(field: "empcode", ascending: true()),
a!sortInfo(field: "type", ascending: true()),
a!sortInfo(field: "amount", ascending: true()),
}

 joinarray(
    a!forEach(
      items: ri!employee,
      expression: concat(
        "<tr>",
        "<td>",
        union(
          { fv!item.empcode },
          { fv!item.empcode }
        ),
        "</td>",
        "<td>",
        if(
          rule!GLB_isBlank(fv!item.barcode),
          {},
          a!localVariables(
            local!code: union(
              { fv!item.barcode },
              { fv!item.barcode }
            ),
            local!newcode: split(local!code, "_"),
            local!newcode[2]
          )
        ),
        "</td>",
        "<td>",
        union(
          { fv!item.empname },
          { fv!item.empname }
        ),
        "</td>",
  
        "<td>",
        fv!item.type,
        "</td>",
 
        "<td>",
        fixed(
          abs(index(fv!item,"amount",{})),
          2
        ),
        "</td>",
        "</tr>"
      )
    ),
    char(10)
  )

  Discussion posts and replies are publicly visible