Data (number) manipulation in grasshopper

Hi guys. I’m trying to build an algorithm that will retrieve random data from a notepad file then order it, group it, assign random value to it. Then orient it according to possible orientation and height.

I’m using a program that generates 100 random values between 9000 to 150000. Each number needs to represent a ‘square’ in the model. Lower number means smaller ‘square’ but if the ‘square’ is higher than the number increases.

E.g. 9560 = small square 1st row, 30000 = small square 7th row. At the moment the the values are assigned randomly.

Also orientations will change the value. For example oriented to ‘south’ increases number required and decreases the number in north.

So I need to divide the data in half. Lower values and higher values. The lower values will randomly get between 1 and 2 and higher values between 2 and 3.

1,2, and 3 represent height 1 is lower third, 2 is middle third and 3 is upper third

There are 8 square sizes to choose from. If given size is not available the algorithm tries to assign the closest value.

For example: 10000 - Choose 2 - Facing South - small square
22000 - Choose 1 - Facing North - small square

I also need to limit number of choices. For example the number can only ‘choose’ 5 biggest squares, 10 medium and 20 small.
I’m really sorry if this doesn’t make sense and if I’m overstepping with this but I only started using grasshopper this Monday.

If you know a solution for even a small part of this question I would be glad.

My random example without organisation factors. (26.8 KB)