The following greedy algorithm always finds the optimum answer:
Choose the lightest pie not yet on a rack
If none of the remaining racks can hold this pie, stop
Of all the racks that can hold this pie, place the pie on the rack with the smallest weight limit
If there are no more pies, stop. Otherwise, go back to step 1
Can be found here.