There are three ways of assuming cost flows:
FIFO stands for "first in, first out." The goods purchased the longest ago are assumed to be sold first.
FIFO is more accurate for balance sheets as the assets left at the end of the month are closest to the current price of purchasing them.
LIFO stands for "last in, first out." The last goods purchased are assumed to be sold first.
LIFO most accurately reflects the costs at the time of sale and is thus most accurate for the income statement. However, this messes up balance sheets.
The third possible assumption averages the costs.