I have an array of objects as shown below:
[
{ pallet: 987, lpn: 1234, city: "London", country: "UK" },
{ pallet: 987, lpn: 5634, city: "London", country: "UK" },
{ pallet: null, lpn: 4933, city: "London", country: "UK" },
{ pallet: 757, lpn: 9264, city: "London", country: "UK" }
]
Expected Behavior:
If the pallet field has a value, the records should be grouped by pallet.
If the pallet field is null, that record should be displayed as a separate, independent row, not part of any group.
Expected Output Structure:
Pallet 987
├─ LPN 1234
└─ LPN 5634
LPN 4933
Pallet 757
└─ LPN 9264