Terminal "ls" command sorting flagged files
You can grep for ‘restricted’ to restrict the results to just restricted files.

$ ls -lO | grep restricted
drwxr-xr-x@   5 root  wheel  restricted         160 21 Sep 05:05 System
drwxr-xr-x@  37 root  wheel  restricted,hidden 1184 21 Sep 05:17 bin
⋮


To sort by file flags, pipe to sort -k 5

$ ls -lO | sort -k 5      
total 20
drwxr-xr-x    2 root  wheel  -                   64  1 Sep 15:47 AppleInternal
⋮
dr-xr-xr-x    2 root  wheel  hidden               1 14 Dec 22:10 home
⋮
-rw-r--r--    1 root  wheel  hidden,compressed  313 18 Aug 01:55 installer.failurerequests
⋮
drwxr-xr-x@   5 root  wheel  restricted         160 21 Sep 05:05 System