Hot answers tagged

410

The proper menu option is as follows. For all versions prior to 6.8.3: Menu Edit → Line Operations → Sort Lines in Ascending / Descending Order For version 6.8.3 and following: Menu Edit → Line Operations → Sort Lines Lexicographically Ascending / Descending Select a few lines and your selection will be sorted. If there's no selection, your entire ...


76

Vim's own :sort command :%sort i does what you want. See :help :sort. Alternatively, you can also use your system's sort command as a filter: :%!sort -f See :help filter in Vim and $ man sort in your shell.


53

It depends on the collation order of your locale: >LANG=en_IE.UTF-8 ls -1 foo* foopa.png foo.png fooqa.png >LANG=C ls -1 foo* foo.png foopa.png fooqa.png You can also use the LC_COLLATE variable instead of LANG, and use the POSIX locale instead of the C one. C collation order is purely alphabetical (ASCII order). Other collation orders (such as ...


42

As you may have realised, your IP addresses are treated as text and not numbers. They are being sorted as text, which means that addresses beginning with "162" will come before addresses beginning with "20." (because the character "1" comes before the character "2". You can use the formula provided in this answer: https://stackoverflow.com/a/31615838/...


35

The Sort-Object cmdlet in PowerShell supports a -Unique switch that does the same thing as uniq: Get-Content file.txt | Sort-Object -unique Of course, owing to presence of aliases in PowerShell, you can also write: type file.txt | sort -unique Additionally, there is an undocumented /unique switch in sort.exe of Windows 10, so, this should work in Command ...


30

sort doesn't create a thread unless it needs to, and for small files it's just too much overhead. Now unfortunately sort treats a pipe like a small file. If you want to feed enough data to 24 threads then you'll need to specify to sort to use a large internal buffer (sort does that automatically when presented with large files). This is something we should ...


23

One other option is to load the file into a Database. E.G MySQL and MySQL Workbench. Databases are perfect candidates for working with large files If your input file contains just words seperated by a new line this shouldn't be to hard. After you've installed the database and MySQL Workbench this is what you'd need to do. First create the schema (this ...


22

For the mac users, you can install coreutils. This formula provides the GNU core utilities implementations, and for the commands that are also provided by macOS, they have been installed with the "g" prefix. brew install coreutils gls --color -h --group-directories-first You can further simplify your life with an alias alias ls='gls --color -h --...


18

As nixda mentioned in the comments, helper columns will make this possible. You have two options for maintaining the sheet afterward: Add all new IPs in the split helper columns. Repeat the Text-to-columns procedure for new additions. Here's the procedure: Select your IP column and click Data > Text-to-Columns Choose the Delimted option and click Next. ...


17

You can sort on multiple columns by shift-clicking. A normal click sets the primary order, shown by the up/down indicator arrow. After that, you can press Shift while clicking on a column header to set the secondary, tertiary, etc. orders. The indicator will remain on the primary column and you can click any of those columns again to toggle the direction. ...


16

What are my options? Try Freeware Command Line Sort Utility CMSort. It uses multiple temporary files and then merges them at the end. CMsort is reading records of an input file until the adjusted memory is reached. Then the records are sorted and written to a temporary file. This will be repeated until all records are processed. Finally, all temporary ...


14

I was still getting inconsistent results with the various solutions. This seemed to work best for me: Open My Documents folder, Select View - Details Either (A) move Date column to the far left or (B) right click on date column, select "More" and move Date to the very top (Move Up button) Click on Date to sort by most recent Select View - Options Select ...


13

Extending user195696's answer: find . -type f -printf "%T@\t%Tc %6k KiB %p\n" | sort -n | cut -f 2- For each file, this first outputs the numeric timestamp (for sorting by, followed by tabulation \t), then a human-readable timestamp, then the filesize (unfortunately find's -printf can't do in mebibytes, only kibibytes), then the filename with relative path....


13

I did some testing and the overall ordering seems to be as follows... Symbols Latin (ordered by Unicode value (U+xxxx)) Greek (ordered by Unicode value (U+xxxx)) Cyrillic (ordered by Unicode value (U+xxxx)) Hebrew (ordered by Unicode value (U+xxxx)) Arabic (ordered by Unicode value (U+xxxx)) Numbers Latin (ordered by Unicode value (U+xxxx)) Greek (...


12

Try this extension (it is called No Message Pane Sort by Mouse); according to the description: No Message Pane Sort prevents accidental resorting of the message pane by disabling mouse button clicks on the column headers. It is still possible to sort messages by ctrl-clicking the header. I tried it myself: it disables sort button and thus should be what ...


10

This can be done easily with PowerShell without any additional tools: $x = Get-Content -Path data.txt; Set-Content -Path data.txt -Value ($x[($x.Length-1)..0])


10

The most easiest, 3 steps Solution I can suggest you are,,, Select the IP Address Column, apply Text to Column command. In adjacent Column write this Formula =CONCATENATE(B3,".",C3,".",D3,".",E3) Finally Sort in Ascending order. Check the Screen Shot. NB: Red is Original IP Address (in Column A). Green after applied Text to Column (Column B to E). ...


9

I realize this is an old post, but in the interest of providing a working solution, I present the following. Just put this formula in an adjacent cell and update the references to point to the cell containing your IP address (A1 in this example). This will produce a result similar to 010.121.008.030, which can then be sorted (correctly) alphabetically. Then ...


9

The described behaviour is probably an effect of locale. Turn off locale settings for sort: $ echo '1.c 19z ' | LC_ALL=C sort 1.c 19z


9

If by "name order" you mean a simple alphabetical sorting, you could just sort the find results, which works fine as long as the files do not contain a newline in their name: find "$PHOTODIR" -iname "*.jpg" | sort If you want to pass these as arguments to an image viewer—or any other command—you need to pipe them to xargs. This works out of the box as long ...


9

Instructions Press + E to open File Explorer, and then click onto the root of the "C" drive Press Ctrl + Shift + 6 to change the root "C" drive folder view to Details view which will add the Date modified column If the Date modified doesn't show here for some reason, then simply right click on one of the other existing columns and then ...


9

Here'a a VBA function I wrote some time ago to solve the same problem. It generates a padded version of an IPv4 address which sorts correctly. Function SortAddress(Address As String) ' format address as XXX.XXX.XXX.XXX to permit sorting Dim FirstByte As Integer, LastByte As Integer, I As Integer SortAddress = "" FirstByte = 1 For I =...


8

On OS X, if you don't want to install homebrew (but you really should), you could use perl or ruby: perl -MList::Util -e 'print List::Util::shuffle <>' or ruby -e 'puts STDIN.readlines.shuffle'


8

I have a simple solution that works for both FreeBSD (OS X) and Linux: find . -type f -exec ls -t {} +


8

Set B2 to =IF(A2=A3, 1, -2) and set B3 to =IF($A2=$A3, B2, IF($A3=$A4, IF(B2>0,3-B2,B2+3), IF(B2>0,-B2,B2))) and drag it down to B30 (or the last row that contains data, whatever that is).  This will evaluate to a positive number if this row is part of a duplicate value group and a negative value if it isn’t (i.e., if Column A contains a unique ...


8

Here is an answer that will take only 1 column of your table and converts the IPv4 address to base 10 numbering. Since you are putting your data in column "M", this starts in cell M2 (M1 being the label). Encapsulating it as code gives one terrible mess, so I have used blockquote: =INT(LEFT(M2, FIND(".", M2) - 1)) * 256 ^ 3 + INT(MID(M2, FIND(".", M2) + ...


8

Operating systems can really only use one of two basic methods, ASCII sorting or Natural sorting ASCII gives this pic credit - http://support.ecisolutions.com/doc-ddms/help/reportsmenu/ascii_sort_order_chart.htm which takes each single element & applies sort rules, without any other interpretation. Natural sort attempts to handle such as numerical ...


8

Actually, the primary sort in the "Top Results" view ( the default ) of most SearchResults folders is a property hidden from dislpay: System.Search.Rank. This can be verified by examining the varous TopViews defined under: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes $FTPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\...


7

You can use the -v option in GNU ls: natural sort of (version) numbers within text. ls -1v cwcch* This does not work with BSD ls (e.g. on OS X), where the -v option has a different meaning.


7

There are certain things I want to see in a directory listing, and so far none of the answers here meets all of the requirements below. My requirements for a directory listing: Directories and files are sorted alphabetically Directories are listed first Symbolic links (symlinks) are sorted like files Sorting is case-insensitive Sorting ignores all leading ...


Only top voted, non community-wiki answers of a minimum length are eligible