Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: how do i alphabetize a list from a text file?

  1. #1
    Join Date
    Aug 2015
    Beans
    390

    how do i alphabetize a list from a text file?

    I have a list of names and contact numbers that is in a txt file, however, the names aren't alphabetized and makes it difficult to navigate through, how do I alphabetize the list?

    I'm running Lubuntu 16.04.

  2. #2
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: how do i alphabetize a list from a text file?

    Please show a typical line from your text file and tell us how you want to alphabetize it. (I would guess that you want to sort it by first name or family name, but I don't know where you have the names in your text files.)

  3. #3
    Join Date
    Dec 2007
    Beans
    12,533

    Re: how do i alphabetize a list from a text file?

    Quote Originally Posted by sudodus View Post
    Please show a typical line from your text file and tell us how you want to alphabetize it. (I would guess that you want to sort it by first name or family name, but I don't know where you have the names in your text files.)
    +1

    The more data OP shares, the easier it will be to answer correctly. Otherwise, one can recommend
    man sort or other online resources such as
    https://www.computerhope.com/unix/usort.htm or
    https://www.ibm.com/developerworks/c...files9?lang=en or
    https://en.wikipedia.org/wiki/Sort_(Unix)

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    15,251
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: how do i alphabetize a list from a text file?

    Quote Originally Posted by ardouronerous View Post
    I have a list of names and contact numbers that is in a txt file, however, the names aren't alphabetized and makes it difficult to navigate through, how do I alphabetize the list?

    I'm running Lubuntu 16.04.
    sort, but this sounds like a homework question.

  5. #5
    Join Date
    Aug 2015
    Beans
    390

    Re: how do i alphabetize a list from a text file?

    The list is like this;
    Code:
    Sarandon, Susan - XXX-XXX-XXX
    Cruise, Tom - XXX-XXX-XXX
    Bale, Christian - XXX-XXX-XXX
    Goldblum, Jeff - XXX-XXX-XXX
    As you can see the list isn't in alphabetical order, I'd like to alphabetize the list.

  6. #6
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: how do i alphabetize a list from a text file?

    If you want to sort according to family name, it is very easy. Assume that the list is in a file with the name unsorted-list.txt,

    Code:
    sort unsorted-list.txt > sorted-list.txt
    and the sorted (alphabetized) result is in the file sorted-list.txt.

  7. #7
    Join Date
    Aug 2015
    Beans
    390

    Re: how do i alphabetize a list from a text file?

    Thank you, that worked!

  8. #8
    Join Date
    Jun 2008
    Location
    Across The Pond
    Beans
    938
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: how do i alphabetize a list from a text file?

    gedit will alphabetize a list for you too.
    "Everybody is ignorant, only on different subjects." Will Rogers

  9. #9
    Join Date
    Dec 2007
    Beans
    12,533

    Re: how do i alphabetize a list from a text file?

    As will LibreOffice Calc and Geany.

  10. #10
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: how do i alphabetize a list from a text file?

    ... LibreOffice Writer and Pluma too....

    By the way, you need to activate the sort plugin in preferences in both gedit and pluma before sort appears in their menus. Or at least I had to in Ubuntu 16.04.
    Ubuntu 16.04 Desktop Guide - Ubuntu 17.10 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •