For most Unix-like systems, like macOS the default sorting order when the ls command is used is alphabetical by file name, i.e. the files are listed in ascending order, from A to Z, and directories are listed first, followed by files.
At times you would like to sort the list by date, especially to know if some files were recently added or modified.
To sort the list by date make use of the -t flag/option.
Example:
% ls -lt
total 16
-rw-r--r-- 1 c2ctech staff 0 May 7 15:56 myfile.txt
drwx------@ 10 c2ctech staff 320 May 7 15:42 Desktop
drwx------+ 120 c2ctech staff 3840 May 6 17:15 Downloads
drwx------@ 93 c2ctech staff 2976 May 6 00:46 Library
drwx------+ 6 c2ctech staff 192 May 5 22:59 Pictures
-rw-r--r--@ 1 c2ctech staff 433 May 3 17:33 gif-gen.py
drwxr-xr-x@ 3 c2ctech staff 96 Apr 25 14:02 Postman
drwx------+ 7 c2ctech staff 224 Apr 22 20:16 Documents
drwxr-xr-x@ 3 c2ctech staff 96 Apr 19 20:09 AndroidStudioProjects
-rw-r--r-- 1 c2ctech staff 29 Apr 18 19:33 vimrc
drwxr-xr-x 5 c2ctech staff 160 Apr 16 10:31 AI
drwx------@ 3 c2ctech staff 96 Apr 13 21:51 Applications
drwxr-xr-x 25 c2ctech staff 800 Apr 5 19:34 anaconda3
drwxr-xr-x@ 5 c2ctech staff 160 Mar 24 14:09 IdeaProjects
drwx------ 4 c2ctech staff 128 Mar 16 13:09 Movies
drwx------ 5 c2ctech staff 160 Mar 16 13:07 iCloud Drive (Archive)
drwx------+ 4 c2ctech staff 128 Mar 16 13:06 Music
drwxr-xr-x+ 4 c2ctech staff 128 Mar 16 13:03 Public
As you may see when I ran the ls -lt command in my current directory which is home (~) gets sorted by modification time, with the most recently modified files and directories first
The next question which is obvious, is how to sort in the reverse order, all you need to do is add -r flag to the -t
% ls -ltr
total 16
drwxr-xr-x+ 4 c2ctech staff 128 Mar 16 13:03 Public
drwx------+ 4 c2ctech staff 128 Mar 16 13:06 Music
drwx------ 5 c2ctech staff 160 Mar 16 13:07 iCloud Drive (Archive)
drwx------ 4 c2ctech staff 128 Mar 16 13:09 Movies
lrwxr-xr-x 1 c2ctech staff 54 Mar 16 13:36 OneDrive - Code2care
drwxr-xr-x@ 5 c2ctech staff 160 Mar 24 14:09 IdeaProjects
drwxr-xr-x 25 c2ctech staff 800 Apr 5 19:34 anaconda3
drwx------@ 3 c2ctech staff 96 Apr 13 21:51 Applications
drwxr-xr-x 5 c2ctech staff 160 Apr 16 10:31 AI
-rw-r--r-- 1 c2ctech staff 29 Apr 18 19:33 vimrc
drwxr-xr-x@ 3 c2ctech staff 96 Apr 19 20:09 AndroidStudioProjects
drwx------+ 7 c2ctech staff 224 Apr 22 20:16 Documents
drwxr-xr-x@ 3 c2ctech staff 96 Apr 25 14:02 Postman
-rw-r--r--@ 1 c2ctech staff 433 May 3 17:33 gif-gen.py
drwx------+ 6 c2ctech staff 192 May 5 22:59 Pictures
drwx------@ 93 c2ctech staff 2976 May 6 00:46 Library
drwx------+ 120 c2ctech staff 3840 May 6 17:15 Downloads
drwx------@ 10 c2ctech staff 320 May 7 15:42 Desktop
-rw-r--r-- 1 c2ctech staff 0 May 7 15:56 myfile.txt

Have Questions? Post them here!
- How to Display content of a file in Terminal Screen?
- How to Install CVS Version Control on Linux/Ubuntu
- How to install and Configure sar sysstat tools in Ubuntu Linux
- ls command to list only directories
- [Ubuntu] Search a package and versions using apt command
- zsh hello world example
- Linux Remove or Delete Files and Directories using Terminal Commands
- How to tar.gz a directory or folder Command
- Calculate days between dates using dateutils ddiff command
- How to ls command to output one entry per line [macOS/Linux/Bash]
- 3 Commands to stop Nginx Server
- Create and write file in single Linux/macOS command
- SCP Copy all files from directory to Local Folder
- How to go to the End of File in Nano Editor
- How to remove/delete a directory in Linux/macOs
- How to Copy Entire Directory to another Directory in Linux
- Execute .bin and .run file Ubuntu Linux
- The Date Command and its usage [Linux - Unix - macOS]
- Fix - ssh-copy-id no identities found error
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to Select All text in vim/vi editor using Keyboard
- Linux: Create a New User and Password and Login Example
- Command to display epoch time Terminal
- How to install curl on Alpine Linux
- How to exit from nano command
- 5 ways to pop out a Chat in Microsoft Teams - Teams
- Customizing Notepad++ New Document Line Encoding: CR/LF/CR LF - NotepadPlusPlus
- Microsoft Teams change default language - Teams
- How to install XML Tools Plugin Notepad++ - NotepadPlusPlus
- Facebook Thanks for stopping by! We hope to see you again soon. - Facebook
- How to change the System Settings Sidebar icon size Mac Ventura 13 - MacOS
- Change Max and Min Value of Android Seekbar Programmatically - Android
- Eclipse : The type java.lang.CharSequence cannot be resolved. Indirectly referenced from required .class files - Java