BUG: fix item cache invalidation bug in #3970 caused by is_mixed_type silently consolidating (hurf). also fix stable sorting bug presenting on my machine