Forum Discussion
KathyB1570
Sep 30, 2024Copper Contributor
Custom Sort for Weight Distribution
I'm trying to figure out a way to sort a list of pallets by weight, but the list needs to have the smallest values at the beginning and end with the highest weights in the middle. Is this possible?
PeterBartholomew1
Sep 30, 2024Silver Contributor
Carrying on the same theme, because messy formulas like that are a distraction in your workbook, it would be possible to define your own function 'AlternatingSortλ' (say)
AlternatingSortλ
=LAMBDA(p,
LET(
stackedSort, VSTACK(SORT(p), SORT(p, , -1)),
TAKE(WRAPROWS(stackedSort, 2), , 1)
)
);
Workheet formula
= AlternatingSortλ(pallets)A slight change to the function would allow it to output Pallet IDs as well as their weights.
PeterBartholomew1
Sep 30, 2024Silver Contributor
Just in case a 365 user comes across this now or in the future, here is the workbook.
- KathyB1570Oct 02, 2024Copper ContributorThat's amazing, thank you! I'll try that today.