Let's say a company with multiple investors liquidates without any explicit agreements to handle this scenario. The company has less cash than the initial investments. Do the early investors get paid first in this scenario? Or is the payout just split according to ownership share?
All shares of the same class are considered equal. Each class of shares may have a different preference in order of repayment.
After all company liabilities have been paid off [including bank debt, wages owing, taxes outstanding, etc etc.], the remaining cash value in a company is distributed to the shareholders. In general, there are 2 types of shares: Preferred shares, and Common shares.
Preferred shares generally have 3 characteristics: (1) they get a stated dividend rate every year, sometimes regardless of company performance; (2) they get paid out first on liquidation; and (3) they can only receive their stated value on liquidation - that is, $1M of preferred shares will be redeemed for at most $1M on liquidation, assuming the corporation has at least that much cash left.
Common Shares generally have 4 characteristics: (1) their dividends are not guaranteed (or may be based on a calculation relative to company performance), (2) they can vote for members of the Board of Directors who ultimately hire the CEO and make similar high level business decisions; (3) they get paid last on liquidation; and (4) they get all value remaining in the company once everyone else has been paid.
So it is not the order of share subscription that matters, it is the class. Once you know how much each class gets, based on the terms listed in that share subscription, you simply divide the total class payout by number of shares, and pay that much for each share a person holds.
For companies organized other-than as corporations, ie: partnerships, the calculation of who-gets-what will be both simpler and more complex. Simpler in that, generally speaking, a partnership interest cannot be of a different 'class', like shares can, meaning all partners are equal relative to the size of their partnership interest. More complex in that, if the initiation of the company was done in an informal way, it could easily become a legal fight as to who contributed what to the company.
This would be governed by bankruptcy law... there is no reason a healthy company would take such action.
This would be a long drawn process generally amongst debtor the taxes have higher claim, then Sunday debtors (payable), then bank loans... This is followed by loan raised by company deposits then debentures... even among share holders there can be special shares...
More often most shares are equal and the balance is distributed to all.
Assuming no debt, as you've specified in the comments to your question, the assets should generally be distributed proportional to ownership share. BUT, without any sort of agreement, there might be contention on what each investor's share is and that might get fought out in court. With a corporation issuing shares, the corporate charter probably defines the relationship between different classes of shares (or specifies only one class). For a partnership though, you could conceivable have people making claims of ownership stake based on labor in addition to any cash that they put up. Messy if there's no up-front agreement.