This tutorial introduces several ways to manage data structures to make a simple inventory system.
Which one is better dictionary or array inventory?
They each have their own advantages, depending mainly on the functionalities required in your game, proficiency in manipulating such data structures, and simply using whichever fits the bill. They're just different ways to help organize your data.
Array have a natural advantage when it comes to sorting. If you want to design a sorting feature, arrays make it convenient to sort certain data. Arrays also have actions like Push and Pop, which can implement task queues like queues and stacks.
dictionary have a huge advantage in retrieval because they can quickly find the corresponding value based on a name. If you need to find a value among thousands of items, a dictionary is definitely much faster than an array because it doesn't need to scan the entire dictionary.
When dealing with complex data, using JSON would be a better choice as it encompasses functionalities of both arrays and dictionaries, allowing for storage of various data types.