How Would You Tackle My Issue? [SOLVED]

Final Edit

Long story short, I was initially stuck on how to process data from a database, at first, I thought about using a 4D array, but it was much easier to just use a collection or an array of structs.... Which is what I've now got in place, HOWEVER, although I had gotten over the first hurdle, I then had to sort, refine and remove duplicated in that array. Sadly, I didn't know what I was doing, as I'm not very experienced with ColdFusion.

Trying to sort an array of structures can be a bit of a pain as it turns out, even for the pros.

EITHER WAY I finally found a way to do it. I created a fairly nice function for it, makes it neat, contained and readable. Then possibly the easiest part of it all was to just return n number of the top rated products/elements from the array that I've had to process.


FYI. If you haven't guessed, the structs contain a key I've named score, which is an accumulation of hwo many different people or how many different times the product was purchased and how much of it was ordered per purchase.


This experience has taught me that it's best to learn a language inside and out, rather than try to do everything 100% by yourself, like the sorting thing, I didn't realise there's a VERY MOTHER F$!KING EASY SOLUTION which is already built into CFML..... I was kinda annoyed when I found it because I had essentially wasted time, but then again, I should've read the API more, so it's my fault really aye? :stuck_out_tongue: :joy:

1 Like