Spreadsheet of transactions and I want to automate sorting payees by category

I have downloaded a big spreadsheet of my bank transactions for documenting tax deductions.(it’s income tax season in the USA)

I want to sort them by category, so that groceries are in one part, medical expenses are in another part, etc.

Is there a way to program the spreadsheet to always know, for instance, that Amtrak and Delta are transportation, Market Basket and Whole Foods are groceries, and categorize all payees?

(i e create a new column on the right called Category, and preload its behavior to automatically respond to the name that is in the Payee column?)

VLOOKUP and pivot-tables in spreadsheets, or you consider to use a database…