I am writing a poker application and trying to figure out how to deal with split pots   

There are three round of betting and each round of betting can have multiple orbits   

Can only bet the chips in front of you  
So if a player is all in a side pot is created  

Hands can tie - in which case the pot is split  

A hand can fold and that is just treated like a losing hand 

PlayerA all in 40 Win  
PlayerB 80 second  
PlayerC 80 last  

Player A would take 120 (win 80 as 40 was his money in)  
Player B would take  80

But you don't know the order until the end  
And when PlayerA went in you don't know how many people are going to call   

What could be good algorithm for this?   
  
This code is C# but really just looking for an approach.  

My initial thought is to just record all the betting for each player      
street, orbit, bet  

Where that gets messy is that in a single orbit you could have multiple players all in for different amounts (bet)       

There are rarely more than 3 orbit in a round   
You could assume there would never be more than 10 as with min raise players would run out of chip