Better yet, slot be picked category if no exact match of the item -- so chunks of dullite should stack themselves next to chunks of sparkley; rice next to carrots; meat next to milk.
There would be a few tricksy item like chunks of metal that would stack next to bars of tin before sparkley, but it would still beat the current logic.
Or at least let us sort inventory while mining / harvesting etc