Is there a way to sort credit before debit for the same day? It seems the order is by time of entry, I understand that I can cheating it by entering credit first, but sometimes it's not possible, so if it's possible to sort it this way will be very helpful.
I assume you're asking because you don't like to see asset accounts temporarily going negative on a single day, which doesn't reflect reality. I find this annoying as well.
AFAIK there is no option to sort credits before debits. I believe you're correct that GnuCash sorts transactions by the time they are created (not modified). So, if you have just a few you want to fix, you can duplicate the transaction for any particular debit, and then delete the original one. This will change the create time of that transaction to now, and then it will display at the end of the day.
I'll admit I do that fixup every once in a while, but mostly I've just come to accept seeing negative numbers sometimes and I don't really worry about it, unless it stays negative for more than 1 day (which could potentially incur overdraft fees).
As a maddening side note, 15 years ago a friend of mine got charged three $35 overdraft fees by her bank in the same day because she had about $500 in her account and used her debit card for gas, then milk and a loaf of bread at White Hen, and then paid her cell phone bill, all of which totaled about $100. But her mortgage payment of $800 came through later that same day and was sorted to be first because as the bank customer support explained, "The mortgage payment is more important and we don't want it to bounce." They were nice enough to fix it because we asked, but who knows how many people they did this to that never noticed or complained.
GnuCash primarily sorts transactions in the register by the date of the transaction. In the absence of transaction numbers, or any other data used for sorting, then multiple transactions for the same day are sorted according to the order in which they were entered.
However, you can force multiple transactions for the same day to appear in a particular order in your register by simply giving each transaction a transaction number as well as a date.
If you are still making payments by cheque, then you will probably want to keep the actual cheque number as the reference for those transactions. If you want another transaction to appear before (or after) the cheque transaction, then just use a lower (or higher) value in the number field for the second transaction. Feel free to make up a suitable number - GnuCash doesn't mind, except it may suggest a "next in sequence" number that you will need to override the next time you record a cheque transaction