Secured creditors are paid first, followed by unsecured creditors. If there is any money left, shareholders are paid.