Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order files by last character of filename in Powershell [closed]

Tags:

powershell

I've been challenged by a friend to do the following:

"Find the quickest and easiest way of sorting a directory listing by the LAST character of the filenames."

He's done it on Linux using the following:

ls | rev | sort | rev 

I'd like to show him the powershell alternative, but I'm only just starting to learn powershell and I can't do it. So, I'm cheating and asking for your help.

like image 279
Richard Garside Avatar asked Dec 04 '09 09:12

Richard Garside


1 Answers

Here's my entry:

ls | sort {"$_"[-1]}

and to get pathological:

ls|sort{"$_"[-1]}
like image 115
Keith Hill Avatar answered Feb 12 '23 06:02

Keith Hill