Your store function calls the MyData initialisation function, which creates a MyData instance, but doesn’t add it to the data property or the sortedArray constant, so neither of them will change.
Try:
let newData = MyData(company: textA.text!, scores: Int(textB.text!)!)
data.append(newData)
You may have to either recalculate your sorted array at this point, or declare it as a computed property so it gets recalculated whenever it’s requested.
This works but when it is printed I can only see the 3rd entry. If i add 5 entries of different names and scores I can only see the first 3. How can I make it so I can see all the entries of data.
Without seeing the code, I couldn’t tell you why it’s not doing what you expect.
At the moment I’d expect that when the store function gets called you’re creating an entry, adding it to the array, resorting the array, and printing all of it. So, for example, make sure you’re not replacing the array or any values in it.