The package dired-quick-sort gives you a pop-up menu with lots of useful options to sort your dired view by name, time, size and extension, and optionally group all of the directories together at the top of the listing. This can be a bit fiddly and dired-quick-sort
makes it really easy.
Install the package with
(use-package dired-quick-sort :ensure t :config (dired-quick-sort-setup))
and then hit S
in a dired buffer to bring up the sorting menu. Your sorting choice is then remembered for new dired buffers.