Hello,
I am making a spreadsheet of apportionment schemes. I'm sure I could find it all done someplace, but I would like to see how to approach this problem. I am stuck on Hamilton's method. If you don't know what that is, it is unimportant - please read on.
I have a column of 50 floating point numbers and an integer between 0 and 50, which I will call N. For purposes of this post, I will call the portion of the floating point number to the right of the decimal point the fraction, so for an entry of 13.876 the fraction is .876
I want to create a new column of 50 integers, where the N entries in the original list with the highest fractions are replaced by their ceilings, and replace the rest by their floors. In other words, the number N tells us how many members of the list get rounded up and then the rest get rounded down. The new list must have the entries in the same order as the ones in the original list.
Conveniently, I have a column of 50 names in alphabetical order corresponding to the 50 original values. So presumably I could take mods of the list to get a list of the fractions, then sort all three lists using the fraction list as the key, take the ceilings and floors now that they are grouped with the ceilings on top and floors on the bottom, and then use the alphabetical list to un-sort back to the original order. That would be easy to do interactively, but I want it all done within the sheet, as a macro, and not only have I never done anything like that before, but it seems quite cumbersome. Can anyone suggest another way to handle this?
Thanks very much.
Bookmarks