An inventory review wants high quantities first. A second consumer expects the original snapshot order. Calling sort() on their shared array makes the first view change the second consumer's input.

For a Shopify 3PL reporting adapter, define ownership of the snapshot before building display views. JavaScript's sort() method changes the array in place. Copying the array protects its order, but still shares the row objects. A view that needs independently editable scalar fields can project new rows before sorting them.

Check both array order and row ownership

This example assumes a dense, previously validated snapshot with unique string SKUs and safe nonnegative integer quantities. It projects only two scalar fields. The descending quantity order is a display rule; equal quantities use a deterministic string comparison of the SKU.

'use strict'; const assert = require('node:assert/strict'); function inventoryView(snapshot) { return snapshot .map(row => ({ sku: row.sku, quantity: row.quantity })) .sort((a, b) => b.quantity - a.quantity || (a.sku < b.sku ? -1 : a.sku > b.sku ? 1 : 0)); } const snapshot = Object.freeze([ Object.freeze({ sku: 'B', quantity: 2 }), Object.freeze({ sku: 'C', quantity: 9 }), Object.freeze({ sku: 'A', quantity: 9 }), Object.freeze({ sku: 'Z', quantity: 0 }) ]); const before = JSON.stringify(snapshot); const view = inventoryView(snapshot); assert.deepEqual(view.map(row => row.sku), ['A', 'C', 'B', 'Z']); assert.equal(JSON.stringify(snapshot), before); assert.notStrictEqual(view, snapshot); for (const row of view) { assert.notStrictEqual(row, snapshot.find(item => item.sku === row.sku)); } assert.deepEqual(inventoryView([...snapshot].reverse()), view); view[0].quantity = 100; assert.equal(snapshot.find(row => row.sku === 'A').quantity, 9); assert.deepEqual(inventoryView([]), []); const sharedRows = [...snapshot]; assert.strictEqual(sharedRows[0], snapshot[0]); assert.throws(() => sharedRows[0].quantity = 8, TypeError); console.log('Inventory view ownership checks passed'); 

Save the example as inventory-view.cjs and run node inventory-view.cjs with Node.js 24. The strict-mode frozen-row check demonstrates that an array copy still shares its rows. The other checks examine source order, separate row identity, tie ordering across a reversed input and a change to the returned view. No warehouse request is sent.

Keep a view separate from a stock decision

A drop shipping report may join supplier data, while a shopify fulfillment review may show warehouse balances. Sorting either view does not reserve stock, refresh an old snapshot or authorize an inventory adjustment.

For China fulfillment, define the quantity field before displaying it. A China 3PL adapter should retain the snapshot's timestamp and scope alongside the view. A larger number appearing first says nothing about whether those units can be committed to new orders.

In a hypothetical technical brief called “International Fulfillment for Folligen,” document the validated input contract and the consumers that share it. This projection copies scalar values only; adding nested objects would require a deliberate ownership decision for those fields.

I work with YX Fulfillment. Its Shopify handover guide provides business context for agreeing data responsibilities. This local reporting example is not a deployed YX connector. Production work also needs schema validation and an agreed meaning for every stock field; displaying a sorted view does not establish either.

Workstations with monitors and printers in a warehouse handling area

Warehouse workstations and equipment.