let say i have a group of kids that get to pick out their three favorite toys. Because the number of toy available is limited, only the kids with he highest grade get their #1 choice 1. the rest get their 2nd or 3rd choice depend on their grade and availability.
<tbody>
</tbody>
kids | grade | # 1 choice1 | # 2 choice2 | # 3 choice | toy | availble | ||
k1 | a | toy 1 | toy 2 | toy 3 | toy 1 | 1 | ||
k2 | b | toy 2 | toy 3 | toy 1 | toy 2 | 2 | ||
k3 | c | toy 3 | toy 2 | toy 1 | toy 3 | 8 | ||
k4 | b | toy 1 | toy 2 | toy 3 | ||||
k5 | a | toy 2 | toy 3 | toy 1 | ||||
k6 | b | toy 2 | toy 3 | toy 1 |
<tbody>
</tbody>