One comment

yes, but this all is still highly inefficient for large set of data. Because you need to store in an array huge amount of data, and lets be honest, arrays are slow, and require loads of memory.
I wish there was a way to do it, using temporary tables instead…