I need to design this stupid data system.
I swear to Order I must be a damn nitwit. For all the design stuff I keep reading, it just never lands in my mind until it's too late: DESIGN FIRST, GOD DAMMIT.
And let that be a lesson to...me.
Well, the basics are fairly easy. Build a function that drops the whole file into an array, then build one that drops the whole *new* file into another one. (See, I'm going to dump the whole line, name:stock:shown, into one single array value. That's so I don't have to figure out how to work multidimensionals properly. Okay, so it's not the right kind of lazy. I still think it'll speed things up significantly.)
Once there's two arrays, it's going to check the new stuff's first entry (because it assumes these are at least *roughly* alphabetic) and spin the other array until the two closest matches are at each end, the one before at the bottom and the one after at the top.
THEN it grabs the new one (because this is the spot it should go into the full inventory) and pushes it onto that array at the bottom.
Repeat, rinse, condition, you get the idea.
Well, I do, mostly. And it'll result in those elements being sorted. Assuming you've started with two sorted arrays, this should be quick.
I'm going to kick back with my whiteboard and work out the code details, and I'll come back once I've gotten to the compiling stage. Should be tomorrow.
And perhaps, from now on, I'll remember what I'm supposed to do first.
God Damn, no! Not cheese!
Yes, yes, design.
Sometimes I feel like a trained ape, honestly.