Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7217979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:25:21+00:00 2026-05-28T21:25:21+00:00

I have just discovered the command :sort n in vim (how did I not

  • 0

I have just discovered the command :sort n in vim (how did I not know about that?!), which has almost done exactly what I need.

What I am trying to sort, though, is a long list of IP addresses (it’s an "allow hosts" file to be Included into our apache config), and it would be nice for :sort n to be able to recognise that 123.45.6.7 should sort before 123.45.16.7 (for example).

Is it a safe assumption that I should be less OCD about it and not worry, because I’m not going to be able to do this without a mildly-complex sed or awk command or something?

To be clear, the rows all look something like:

Allow from 1.2.3.4
Allow from 5.6.7.8
Allow from 9.10.11.12

etc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:25:21+00:00Added an answer on May 28, 2026 at 9:25 pm

    Vim sort seems to be stable in practice (but it is not guaranteed). Therefore you can try:

    :%sort n /.*\./
    :%sort n /\.\d\+\./
    :%sort n /\./
    :%sort n
    

    Which will sort by number after the last dot (* is greedy), then by number after the first dot following a dot and digits, then by number after the first dot, and last by the first number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just discovered LLVM and don't know much about it yet. I have
I have just discovered the taglist plugin for vim, and read about how to
I have just discovered the nifty unhandled exception handler for cocoa-touch. Now that I
I have just discovered that if generating assemblies via Reflection.Emit, the .NET framework keeps
I have just discovered a variable name that is misspelled. If it were hidden
I just discovered the what c# knowledge should I have? question and wondered about
I have a website, and I just discovered that somehow someone injected JavaScript on
I have just discovered that SQL Server CE doesn't allow you to batch queries.
I have just discovered a package for R to retrieve abstract from pubmed, which
I just discovered something that I found odd. I have mys listbox with several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.