I have multiple msg.payloads and i want to pick out the two lowest values out for these.
I'm aware of the $min(payload) but this will only pick out the lowest value, I also want the second lowest value.
The use of the function will be to pick out the two lowest price hours and start an action with these values
JUst for info, the context can be fetched as an array.
let output = flow.get(["h01","h02","h03","h04","h05"]).sort((a,b) => a - b);
msg.payload = output; //msg.payload[0] is lowest msg.payload[1] is next lowest etc
return msg;
Sometimes some values are exact same. And most of the times it doesn't really matter. But sometimes it does.
Just saying cos most of the times that little edge case isn't even considered.