Can I flip the order of text with a Windows program?

P

Paul

Metspitzer said:
On 07/04/2012 6:07 PM, Metspitzer wrote:
[...]
It does have dates but sometimes I used the month day year and
sometimes only month and year.

They are listed in chronological order.
When using a spreadsheet, you have to be careful to specify the cell
format as "date", specify the date format you will use, and never, ever
depart from it. Otherwise, the items won't sort correctly by date.

You can "sort by paragraph" in a word-processor, ie, you end each item
with "Enter", which makes it a paragraph. Place the date at the
beginning, and use leading zeroes, otherwise November 8, 2011 (11-8-12)
will sort before August 4, 2010 (8-4-10). But 11-08-12 will sort
correctly after 02-02-10.

However, if you want to ensure the items are sorted correctly by year,
you'll have to use year-month-day (yyyy-mm-dd).

HTH,
Wolf K.
Thanks
You can use a port of "sort".

There is a sort in Coreutils package.

http://gnuwin32.sourceforge.net/packages.html

This is the contents of my download directory.

http://img69.imageshack.us/img69/3088/coreutils.gif

The "...bin.zip" package holds "sort.exe" file.
The "...dep.zip" package has the support DLLs (dependencies) libiconv2.dll and libintl3.dll
The "...doc.zip" package has things like the PDF files.

To work from a Command Prompt window, the three files (.exe and two DLLs)
have to be in the %PATH%. If they're in the same directory as the
data you're working on, then you should be OK then. CD (change directory)
to the folder with both program and data file, and away you go.

Sort works best, if each line can be separated into fields,
and you then tell sort which field to sort on. It can
get quite complicated, getting sort to do a good job. But
if your file has any size at all, it's worth it. And on
modern computers, it takes no time at all to run.

I think Sort has a "unique" option, whereby multiple identical
lines next to each other, can be removed. The Coreutils package
also has a copy of uniq.exe, which will also remove identical lines
from a file.

apple apple
baker --------> baker
baker uniq.exe dog
dog

Of course you're not going to use it, but it's nice to know it's there.
(It's a ported program from Unix/Linux, and I expect, quite old.)

I also have a scripting language, with a "sort" in it, but that's even
more obscure.

*******

Spreadsheets are the way to go with sorting, because then you get your
"columns" in order. To use a spreadsheet, you need a delimiter to separate
the columns. Some people, when preparing lists, use "tab separation" between
each column. And the sorting tools, spreadsheets or programs, can also be
instructed to use the delimiter of your choice. The last time I had some
data to delimit, I used "|" vertical bar, but tabs or commas are also
popular ways to separate the fields.

*******

When you ask a question like this, it helps to provide a couple bogus
example lines you wanted sorted. And then indicate the first field to
sort on, the second field to sort on, and so on. Perhaps you'd want
"date, last name, first name" or somesuch. And then people can see
what kind of tool makes it easy or hard. Computers are not miracle
workers, and if the information is in a variety of formats (like several
kinds of date fields, not just one format), you'd need something pretty
fancy to fix it. (In this example, \t means "tab" character.) This
example would actually be pretty miserable to deal with. A first step,
would be replacing the "," with a tab perhaps, which you might be
able to do in your text editor.

Doe, John \t Dec.05,2012 \t Plumber \t Tulsa
Lou, Mary \t Apr.01,2012 \t Carpenter \t Boise

HTH,
Paul
 
V

VanguardLH

Metspitzer said:
I started a list in chronological order with older first. I would
like to switch to newest first. Most of it is a single line. Can
this be done with Windows?
Does "text" mean it is a text file where you have the lines of strings
you want to reverse their sorting order? If so, in a command shell,
run:

sort /?
 
J

J. P. Gilliver (John)

Steve Hayes said:
Most decent word processors can do that, but I don't think Windows on its own
can. You might be able to write a batch file to do it.
How would you do it in Word, WordPerfect, or WordPad? My understanding
is that he wants to change some text

with lines
in it
like this

so that it looks thus

like this
in it
with lines

and I certainly don't know how I'd do that in any word processor I use.
(I'd probably use the suggestion others have made of putting it into
Excel or another spreadsheet, adding a number column, reverse sorting on
that column, then either deleting that column before saving back or
saving back excluding that column.)
 
S

Stewart

Metspitzer said:
It is a text file. I wanted to use Wordpad or Notepad or something
else included in Windows.
Pull it into a spreadsheet.
 
R

ray

Metspitzer said:
On 07/04/2012 6:07 PM, Metspitzer wrote: [...]
It does have dates but sometimes I used the month day year and
sometimes only month and year.

They are listed in chronological order.
When using a spreadsheet, you have to be careful to specify the cell
format as "date", specify the date format you will use, and never,
ever depart from it. Otherwise, the items won't sort correctly by
date.

You can "sort by paragraph" in a word-processor, ie, you end each item
with "Enter", which makes it a paragraph. Place the date at the
beginning, and use leading zeroes, otherwise November 8, 2011
(11-8-12) will sort before August 4, 2010 (8-4-10). But 11-08-12 will
sort correctly after 02-02-10.

However, if you want to ensure the items are sorted correctly by year,
you'll have to use year-month-day (yyyy-mm-dd).

HTH,
Wolf K.
Thanks
You can use a port of "sort".

There is a sort in Coreutils package.

http://gnuwin32.sourceforge.net/packages.html

This is the contents of my download directory.

http://img69.imageshack.us/img69/3088/coreutils.gif

The "...bin.zip" package holds "sort.exe" file. The "...dep.zip" package
has the support DLLs (dependencies) libiconv2.dll and libintl3.dll The
"...doc.zip" package has things like the PDF files.

To work from a Command Prompt window, the three files (.exe and two
DLLs) have to be in the %PATH%. If they're in the same directory as the
data you're working on, then you should be OK then. CD (change
directory) to the folder with both program and data file, and away you
go.

Sort works best, if each line can be separated into fields, and you then
tell sort which field to sort on. It can get quite complicated, getting
sort to do a good job. But if your file has any size at all, it's worth
it. And on modern computers, it takes no time at all to run.

I think Sort has a "unique" option, whereby multiple identical lines
next to each other, can be removed. The Coreutils package also has a
copy of uniq.exe, which will also remove identical lines from a file.

apple apple
baker --------> baker
baker uniq.exe dog
dog

Of course you're not going to use it, but it's nice to know it's there.
(It's a ported program from Unix/Linux, and I expect, quite old.)

I also have a scripting language, with a "sort" in it, but that's even
more obscure.

*******

Spreadsheets are the way to go with sorting, because then you get your
"columns" in order. To use a spreadsheet, you need a delimiter to
separate the columns. Some people, when preparing lists, use "tab
separation" between each column. And the sorting tools, spreadsheets or
programs, can also be instructed to use the delimiter of your choice.
The last time I had some data to delimit, I used "|" vertical bar, but
tabs or commas are also popular ways to separate the fields.

*******

When you ask a question like this, it helps to provide a couple bogus
example lines you wanted sorted. And then indicate the first field to
sort on, the second field to sort on, and so on. Perhaps you'd want
"date, last name, first name" or somesuch. And then people can see what
kind of tool makes it easy or hard. Computers are not miracle workers,
and if the information is in a variety of formats (like several kinds of
date fields, not just one format), you'd need something pretty fancy to
fix it. (In this example, \t means "tab" character.) This example would
actually be pretty miserable to deal with. A first step, would be
replacing the "," with a tab perhaps, which you might be able to do in
your text editor.

Doe, John \t Dec.05,2012 \t Plumber \t Tulsa Lou, Mary \t
Apr.01,2012 \t Carpenter \t Boise

HTH,
Paul
Don't know if it's included, but 'tac' (backwards cat) does nothing more
than reverse the order of lines in a file. That would obviously be the
simplest solution.
 
K

Ken Blake

How would you do it in Word, WordPerfect, or WordPad? My understanding
is that he wants to change some text

with lines
in it
like this

so that it looks thus

like this
in it
with lines

and I certainly don't know how I'd do that in any word processor I use.


I use WordPerfect X5. I just pasted

with lines
in it
like this

into a blank document and clicked Tools|Sort. It sorted it to

like this
in it
with lines


And I remember doing the same thing with older version of WordPerfect.
 
J

J. P. Gilliver (John)

Ken Blake said:
On Sun, 8 Apr 2012 12:44:38 +0100, "J. P. Gilliver (John)"
How would you do it in Word, WordPerfect, or WordPad? My understanding
[]
I use WordPerfect X5. I just pasted []
into a blank document and clicked Tools|Sort. It sorted it to []
And I remember doing the same thing with older version of WordPerfect.
Wow; useful. I don't think Word (or WordPad) can do it!
 
N

Nil

Does "text" mean it is a text file where you have the lines of
strings you want to reverse their sorting order? If so, in a
command shell, run:

sort /?
That doesn't seem to do what's required here. SORT will order it in
reverse alphanumeric order, but not reverse "arbitrary" order.

I didn't know about this command. I think it's something I'll use!
 
S

Steve Hayes

How would you do it in Word, WordPerfect, or WordPad? My understanding
is that he wants to change some text
Actually, yes, it would be difficult if he wants to reverse the
*chronological* order, rather than the alphabetical order.

As other have suggested, a spreadsheet would work best for that.

AWK might be able to do it, but I've very little understanding of it.


with lines
in it
like this

so that it looks thus

like this
in it
with lines
No, most word processors I used would change it to

in it
like this
with lines

in alphabetical order.

In Word 97

You would go to Table --> Sort
and tell it if you wanted to sort alphabetically, by number or by date, and
ascending or descending.

In Word 2010 you'd probably have to play with a bunch of ribbons to find how
to do it.
and I certainly don't know how I'd do that in any word processor I use.
(I'd probably use the suggestion others have made of putting it into
Excel or another spreadsheet, adding a number column, reverse sorting on
that column, then either deleting that column before saving back or
saving back excluding that column.)
If you've got Excel, you should have Word, so see above.
 
S

Steve Hayes

Ken Blake said:
On Sun, 8 Apr 2012 12:44:38 +0100, "J. P. Gilliver (John)"
Most decent word processors can do that, but I don't think Windows
on its own
can. You might be able to write a batch file to do it.


How would you do it in Word, WordPerfect, or WordPad? My understanding
[]
I use WordPerfect X5. I just pasted []
into a blank document and clicked Tools|Sort. It sorted it to []
And I remember doing the same thing with older version of WordPerfect.
Wow; useful. I don't think Word (or WordPad) can do it!
Word does it, as described in earlier message. Table --> Sort

Yes, putting it under Table instead of Tools was silly, which is perhaps why
you didn't know where to find it, and they've probably put it somewhere even
sillier in the latest version.
 
S

Steve Hayes

alt.windows7.general:

That doesn't seem to do what's required here. SORT will order it in
reverse alphanumeric order, but not reverse "arbitrary" order.

I didn't know about this command. I think it's something I'll use!
It can do quite a lot --- this is what you get when you type it.


SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]

[[drive1:][path1]filename1] [/T [drive2:][path2]]

[/O [drive3:][path3]filename3]

/+n Specifies the character number, n, to

begin each comparison. /+3 indicates that

each comparison should begin at the 3rd

character in each line. Lines with fewer

than n characters collate before other lines.

By default comparisons start at the first

character in each line.

/L[OCALE] locale Overrides the system default locale with

the specified one. The ""C"" locale yields

the fastest collating sequence and is

currently the only alternative. The sort

is always case insensitive.

/M[EMORY] kilobytes Specifies amount of main memory to use for

the sort, in kilobytes. The memory size is

always constrained to be a minimum of 160

kilobytes. If the memory size is specified

the exact amount will be used for the sort,

regardless of how much main memory is

available.



The best performance is usually achieved by

not specifying a memory size. By default the

sort will be done with one pass (no temporary

file) if it fits in the default maximum

memory size, otherwise the sort will be done

in two passes (with the partially sorted data

being stored in a temporary file) such that

the amounts of memory used for both the sort

and merge passes are equal. The default

maximum memory size is 90% of available main

memory if both the input and output are

files, and 45% of main memory otherwise.

/REC[ORD_MAXIMUM] characters Specifies the maximum number of characters

in a record (default 4096, maximum 65535).

/R[EVERSE] Reverses the sort order; that is,

sorts Z to A, then 9 to 0.

[drive1:][path1]filename1 Specifies the file to be sorted. If not

specified, the standard input is sorted.

Specifying the input file is faster than

redirecting the same file as standard input.

/T[EMPORARY]

[drive2:][path2] Specifies the path of the directory to hold

the sort's working storage, in case the data

does not fit in main memory. The default is

to use the system temporary directory.

/O[UTPUT]

[drive3:][path3]filename3 Specifies the file where the sorted input is

to be stored. If not specified, the data is

written to the standard output. Specifying

the output file is faster than redirecting

standard output to the same file.
 
P

Paul

ray said:
Metspitzer said:
On 07/04/2012 6:07 PM, Metspitzer wrote: [...]
It does have dates but sometimes I used the month day year and
sometimes only month and year.

They are listed in chronological order.
When using a spreadsheet, you have to be careful to specify the cell
format as "date", specify the date format you will use, and never,
ever depart from it. Otherwise, the items won't sort correctly by
date.

You can "sort by paragraph" in a word-processor, ie, you end each item
with "Enter", which makes it a paragraph. Place the date at the
beginning, and use leading zeroes, otherwise November 8, 2011
(11-8-12) will sort before August 4, 2010 (8-4-10). But 11-08-12 will
sort correctly after 02-02-10.

However, if you want to ensure the items are sorted correctly by year,
you'll have to use year-month-day (yyyy-mm-dd).

HTH,
Wolf K.
Thanks
You can use a port of "sort".

There is a sort in Coreutils package.

http://gnuwin32.sourceforge.net/packages.html

This is the contents of my download directory.

http://img69.imageshack.us/img69/3088/coreutils.gif

The "...bin.zip" package holds "sort.exe" file. The "...dep.zip" package
has the support DLLs (dependencies) libiconv2.dll and libintl3.dll The
"...doc.zip" package has things like the PDF files.

To work from a Command Prompt window, the three files (.exe and two
DLLs) have to be in the %PATH%. If they're in the same directory as the
data you're working on, then you should be OK then. CD (change
directory) to the folder with both program and data file, and away you
go.

Sort works best, if each line can be separated into fields, and you then
tell sort which field to sort on. It can get quite complicated, getting
sort to do a good job. But if your file has any size at all, it's worth
it. And on modern computers, it takes no time at all to run.

I think Sort has a "unique" option, whereby multiple identical lines
next to each other, can be removed. The Coreutils package also has a
copy of uniq.exe, which will also remove identical lines from a file.

apple apple
baker --------> baker
baker uniq.exe dog
dog

Of course you're not going to use it, but it's nice to know it's there.
(It's a ported program from Unix/Linux, and I expect, quite old.)

I also have a scripting language, with a "sort" in it, but that's even
more obscure.

*******

Spreadsheets are the way to go with sorting, because then you get your
"columns" in order. To use a spreadsheet, you need a delimiter to
separate the columns. Some people, when preparing lists, use "tab
separation" between each column. And the sorting tools, spreadsheets or
programs, can also be instructed to use the delimiter of your choice.
The last time I had some data to delimit, I used "|" vertical bar, but
tabs or commas are also popular ways to separate the fields.

*******

When you ask a question like this, it helps to provide a couple bogus
example lines you wanted sorted. And then indicate the first field to
sort on, the second field to sort on, and so on. Perhaps you'd want
"date, last name, first name" or somesuch. And then people can see what
kind of tool makes it easy or hard. Computers are not miracle workers,
and if the information is in a variety of formats (like several kinds of
date fields, not just one format), you'd need something pretty fancy to
fix it. (In this example, \t means "tab" character.) This example would
actually be pretty miserable to deal with. A first step, would be
replacing the "," with a tab perhaps, which you might be able to do in
your text editor.

Doe, John \t Dec.05,2012 \t Plumber \t Tulsa Lou, Mary \t
Apr.01,2012 \t Carpenter \t Boise

HTH,
Paul
Don't know if it's included, but 'tac' (backwards cat) does nothing more
than reverse the order of lines in a file. That would obviously be the
simplest solution.
I use "gawk.exe", the GNU version of "Awk" programming language, to
process text files. I think there might even be an example in the manual,
of how to reverse lines. They're stored in an array, and then played
back in reverse order at the end of the script.

*******

http://gnuwin32.sourceforge.net/packages/gawk.htm

# Pg.137 Example program

{ l[lines++] = $0 } # Store the entire file in a memory array

END { # Print in reverse order once the file is processed
for (i = lines - 1; i >= 0; --i)
print l
}

Command line syntax for that example program would be

gawk -f reverse.awk input.txt > output.txt

*******

People are more familiar with PERL, which is a much more powerful package.
(There is a free version of PERL available as ActivePERL.)
For me, "Awk" is about all I can handle. I own one book on Awk, but
had to buy two for PERL to write a program :)

Paul
 
M

Metspitzer

ray said:
Metspitzer wrote:
On 07/04/2012 6:07 PM, Metspitzer wrote: [...]
It does have dates but sometimes I used the month day year and
sometimes only month and year.

They are listed in chronological order.
When using a spreadsheet, you have to be careful to specify the cell
format as "date", specify the date format you will use, and never,
ever depart from it. Otherwise, the items won't sort correctly by
date.

You can "sort by paragraph" in a word-processor, ie, you end each item
with "Enter", which makes it a paragraph. Place the date at the
beginning, and use leading zeroes, otherwise November 8, 2011
(11-8-12) will sort before August 4, 2010 (8-4-10). But 11-08-12 will
sort correctly after 02-02-10.

However, if you want to ensure the items are sorted correctly by year,
you'll have to use year-month-day (yyyy-mm-dd).

HTH,
Wolf K.
Thanks
You can use a port of "sort".

There is a sort in Coreutils package.

http://gnuwin32.sourceforge.net/packages.html

This is the contents of my download directory.

http://img69.imageshack.us/img69/3088/coreutils.gif

The "...bin.zip" package holds "sort.exe" file. The "...dep.zip" package
has the support DLLs (dependencies) libiconv2.dll and libintl3.dll The
"...doc.zip" package has things like the PDF files.

To work from a Command Prompt window, the three files (.exe and two
DLLs) have to be in the %PATH%. If they're in the same directory as the
data you're working on, then you should be OK then. CD (change
directory) to the folder with both program and data file, and away you
go.

Sort works best, if each line can be separated into fields, and you then
tell sort which field to sort on. It can get quite complicated, getting
sort to do a good job. But if your file has any size at all, it's worth
it. And on modern computers, it takes no time at all to run.

I think Sort has a "unique" option, whereby multiple identical lines
next to each other, can be removed. The Coreutils package also has a
copy of uniq.exe, which will also remove identical lines from a file.

apple apple
baker --------> baker
baker uniq.exe dog
dog

Of course you're not going to use it, but it's nice to know it's there.
(It's a ported program from Unix/Linux, and I expect, quite old.)

I also have a scripting language, with a "sort" in it, but that's even
more obscure.

*******

Spreadsheets are the way to go with sorting, because then you get your
"columns" in order. To use a spreadsheet, you need a delimiter to
separate the columns. Some people, when preparing lists, use "tab
separation" between each column. And the sorting tools, spreadsheets or
programs, can also be instructed to use the delimiter of your choice.
The last time I had some data to delimit, I used "|" vertical bar, but
tabs or commas are also popular ways to separate the fields.

*******

When you ask a question like this, it helps to provide a couple bogus
example lines you wanted sorted. And then indicate the first field to
sort on, the second field to sort on, and so on. Perhaps you'd want
"date, last name, first name" or somesuch. And then people can see what
kind of tool makes it easy or hard. Computers are not miracle workers,
and if the information is in a variety of formats (like several kinds of
date fields, not just one format), you'd need something pretty fancy to
fix it. (In this example, \t means "tab" character.) This example would
actually be pretty miserable to deal with. A first step, would be
replacing the "," with a tab perhaps, which you might be able to do in
your text editor.

Doe, John \t Dec.05,2012 \t Plumber \t Tulsa Lou, Mary \t
Apr.01,2012 \t Carpenter \t Boise

HTH,
Paul
Don't know if it's included, but 'tac' (backwards cat) does nothing more
than reverse the order of lines in a file. That would obviously be the
simplest solution.
I use "gawk.exe", the GNU version of "Awk" programming language, to
process text files. I think there might even be an example in the manual,
of how to reverse lines. They're stored in an array, and then played
back in reverse order at the end of the script.

*******

http://gnuwin32.sourceforge.net/packages/gawk.htm

# Pg.137 Example program

{ l[lines++] = $0 } # Store the entire file in a memory array

END { # Print in reverse order once the file is processed
for (i = lines - 1; i >= 0; --i)
print l
}

Command line syntax for that example program would be

gawk -f reverse.awk input.txt > output.txt

*******

People are more familiar with PERL, which is a much more powerful package.
(There is a free version of PERL available as ActivePERL.)
For me, "Awk" is about all I can handle. I own one book on Awk, but
had to buy two for PERL to write a program :)

Paul


Thanks for your suggestions, but I really don't care to use any 3rd
party stuff on my computer.

I did try to use Google Docs spread sheet and post the text into
column B, but I was not smart enough to figure out how to
automatically put numbers in column A.

Here is a short example of what I am trying to sort. Although I do
have the dates as the first part of the text, what I am shooting for
is to just flip the order of each line with the last line in the text
document to become the first line, like a previous example.

6/22/1965 Broken left Collarbone
3/1966 Broken jaw
9/1975 Broken right hand


9/1975 Broken right hand
3/1966 Broken jaw
6/22/1965 Broken left Collarbone
 
N

Nil

It can do quite a lot --- this is what you get when you type it.
Right, but can it do what the OP asked for? As far as I can see... no.
It can only sort alphanumerically or the reverse.
SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]

[[drive1:][path1]filename1] [/T [drive2:][path2]]

[/O [drive3:][path3]filename3]

/+n Specifies the character number, n,
to

begin each comparison. /+3
indicates that

each comparison should begin at the
3rd

character in each line. Lines with
fewer

than n characters collate before
other lines.

By default comparisons start at the
first

character in each line.

/L[OCALE] locale Overrides the system default locale
with

the specified one. The ""C"" locale
yields

the fastest collating sequence and
is

currently the only alternative. The
sort

is always case insensitive.

/M[EMORY] kilobytes Specifies amount of main memory to
use for

the sort, in kilobytes. The memory
size is

always constrained to be a minimum
of 160

kilobytes. If the memory size is
specified

the exact amount will be used for
the sort,

regardless of how much main memory
is

available.



The best performance is usually
achieved by

not specifying a memory size. By
default the

sort will be done with one pass (no
temporary

file) if it fits in the default
maximum

memory size, otherwise the sort will
be done

in two passes (with the partially
sorted data

being stored in a temporary file)
such that

the amounts of memory used for both
the sort

and merge passes are equal. The
default

maximum memory size is 90% of
available main

memory if both the input and output
are

files, and 45% of main memory
otherwise.

/REC[ORD_MAXIMUM] characters Specifies the maximum number of
characters

in a record (default 4096, maximum
65535).

/R[EVERSE] Reverses the sort order; that is,

sorts Z to A, then 9 to 0.

[drive1:][path1]filename1 Specifies the file to be sorted. If
not

specified, the standard input is
sorted.

Specifying the input file is faster
than

redirecting the same file as
standard input.

/T[EMPORARY]

[drive2:][path2] Specifies the path of the directory
to hold

the sort's working storage, in case
the data

does not fit in main memory. The
default is

to use the system temporary
directory.

/O[UTPUT]

[drive3:][path3]filename3 Specifies the file where the sorted
input is

to be stored. If not specified, the
data is

written to the standard output.
Specifying

the output file is faster than
redirecting

standard output to the same file.
 
P

Paul

Metspitzer said:
Thanks for your suggestions, but I really don't care to use any 3rd
party stuff on my computer.

I did try to use Google Docs spread sheet and post the text into
column B, but I was not smart enough to figure out how to
automatically put numbers in column A.

Here is a short example of what I am trying to sort. Although I do
have the dates as the first part of the text, what I am shooting for
is to just flip the order of each line with the last line in the text
document to become the first line, like a previous example.

6/22/1965 Broken left Collarbone
3/1966 Broken jaw
9/1975 Broken right hand


9/1975 Broken right hand
3/1966 Broken jaw
6/22/1965 Broken left Collarbone
The hardest part of what you're trying to do, is getting software
to recognize the dates. Date formats are "hard" things. As humans,
we can instantly spot your 6/22 as Jun.22 and your 3 as March, and
make sense out of it. But a computer, unless the software is pretty
damn fancy, will have trouble digesting those. There are so many
different date formats, it would be difficult to write a routine
that detected all of them successfully. And as a result, when you
go to sort, you're going to find that no matter what you sort with,
there will be errors.

The situation improves slightly, if you changed 3/1966 to 3/1/1966
implying the event happened on the first of the month. In other
words, "pad out" some of the strings, to match the other strings.
Of course, that also affects what you were trying to say, which is
"sometime in March". Changing to 3/1/1966 implies it happened
precisely on the first day of the month, and that might not be
your intended message.

I can write code to handle your two cases (in other words, not
change anything, and still get it right). I could make a custom sorting
program (script), to do the job accurately. But then that violates
your "pristine" computer requirement :)

The pseudo-code would look something like this.

Read in the text
Store the text in two arrays, with a numeric index for each line.
In one of the arrays, reformat the text in a "computer friendly" form.

(That's what my scripting language does best.) Here, the sorting fields
are arranged in columns of fixed field width. Adding a leading zero to
some of the fields, makes them easier to sort with precision. The "blank"
fields can be replaced with another placeholder string, if the sort order
isn't coming out right.

06 22 1965 Broken left Collarbone 1
03 1966 Broken jaw 2
09 1975 Broken right hand 3 <--- the index added to end

Call an external sorting routing, sorting by column 1, column 2, column 3.
Read the sorted "computer friendly" array back into the script.
Read out the "original" array, in the same order as the "computer friendly"
version and print it out. (The index number, is how you figure out which
"computer friendly" line, corresponds to an array entry in the "original"
content storage array.)

By doing it that way, I don't affect the semantics of what you
were trying to say in your list. The "computer friendly" array is
thrown away and not recorded, and is just part of a private
conversation between two pieces of computer code.

You can do something similar to this, in Excel, but just like my scripting
language, Excel isn't that clever either. It would take a *lot* of massaging
in Excel, to make the "computer friendly" format intermediary.

Perhaps PERL has enough stuff, to do this completely internally,
but I don't know enough PERL to know that for sure.

Paul
 
M

Metspitzer

The hardest part of what you're trying to do, is getting software
to recognize the dates. Date formats are "hard" things. As humans,
we can instantly spot your 6/22 as Jun.22 and your 3 as March, and
The suggestion to just make a row of numbers in column A and just
ignore what is in column B seems like it would be the right answer.
Can't a spreadsheet just ignore column B?
make sense out of it. But a computer, unless the software is pretty
damn fancy, will have trouble digesting those. There are so many
different date formats, it would be difficult to write a routine
that detected all of them successfully. And as a result, when you
go to sort, you're going to find that no matter what you sort with,
there will be errors.

The situation improves slightly, if you changed 3/1966 to 3/1/1966
implying the event happened on the first of the month. In other
words, "pad out" some of the strings, to match the other strings.
Of course, that also affects what you were trying to say, which is
"sometime in March". Changing to 3/1/1966 implies it happened
precisely on the first day of the month, and that might not be
your intended message.

I can write code to handle your two cases (in other words, not
change anything, and still get it right). I could make a custom sorting
program (script), to do the job accurately. But then that violates
your "pristine" computer requirement :)

The pseudo-code would look something like this.

Read in the text
Store the text in two arrays, with a numeric index for each line.
In one of the arrays, reformat the text in a "computer friendly" form.

(That's what my scripting language does best.) Here, the sorting fields
are arranged in columns of fixed field width. Adding a leading zero to
some of the fields, makes them easier to sort with precision. The "blank"
fields can be replaced with another placeholder string, if the sort order
isn't coming out right.

06 22 1965 Broken left Collarbone 1
03 1966 Broken jaw 2
09 1975 Broken right hand 3 <--- the index added to end

Call an external sorting routing, sorting by column 1, column 2, column 3.
Read the sorted "computer friendly" array back into the script.
If the spreadsheet could just ignore column A and sort with numbers in
column B would get it done also.
Read out the "original" array, in the same order as the "computer friendly"
version and print it out. (The index number, is how you figure out which
"computer friendly" line, corresponds to an array entry in the "original"
content storage array.)

By doing it that way, I don't affect the semantics of what you
were trying to say in your list. The "computer friendly" array is
thrown away and not recorded, and is just part of a private
conversation between two pieces of computer code.

You can do something similar to this, in Excel, but just like my scripting
language, Excel isn't that clever either. It would take a *lot* of massaging
in Excel, to make the "computer friendly" format intermediary.

Perhaps PERL has enough stuff, to do this completely internally,
but I don't know enough PERL to know that for sure.

Paul
Thanks
 
K

Ken Blake

Usually better is 03/01/1966.




Or on the third of January, depending on what country you are in.
 
J

J. P. Gilliver (John)

In message <[email protected]>, Steve Hayes
Word does it, as described in earlier message. Table --> Sort

Yes, putting it under Table instead of Tools was silly, which is perhaps why
Because they'd run out of more sensible places to put it ...
you didn't know where to find it, and they've probably put it somewhere even
sillier in the latest version.
.... was the reason given by the enthusiastic Microsoft chap they sent us
for why they introduced the ribbon - that the older version (we went
from 2003 to 2010) had got to the point where, when they added a
function, they squeezed it in wherever there was room, well beyond the
point that the new functions were added in a logical position. I see his
point, but I'd learnt where most of the functions I wanted were,
illogical or not (-:!

However: I don't think the sort you describe will do what the OP wanted
- basically reverse the order of lines in a file, not sort in any sort
of order.
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G.5AL-IS-P--Ch++(p)Ar@T0H+Sh0!:`)DNAf

.... his charming, bumbling best, a serial monogamist terrified of commitment,
who comes across as a sort of Bertie Wooster but with a measurable IQ. - Barry
Norman on Hugh Grant's persona in certain films, Radio Times 3-9 July 2010
 
W

Wolf K

On 08/04/2012 3:24 PM, Metspitzer wrote:
[...]
Here is a short example of what I am trying to sort. Although I do
have the dates as the first part of the text, what I am shooting for
is to just flip the order of each line with the last line in the text
document to become the first line, like a previous example.

6/22/1965 Broken left Collarbone
3/1966 Broken jaw
9/1975 Broken right hand


9/1975 Broken right hand
3/1966 Broken jaw
6/22/1965 Broken left Collarbone
This is actually very simple to do in any word-processor or text editor
that Sorts by paragraph or line. Wordpad and Notepad won't do this. Any
word-processor will do so, and many text editors will, too.

Note that the word-processor doesn't recognise dates as such. A date is
just another string of characters, made up of numerals and slashes
instead of letters. Sort arranges by 1st character in the string, if two
strings have the same first character, then the 2nd character governs,
if the first 2 characters are the same, then the 3rd character governs,
and so on. and so on.

So, Sort will rewrite your example as:

3/1966 ...
6/22/1965 ...
9/1975 ...

This Sort is by month, then day, year, which is not what you want.

To make Sort work as you want, you'll have to develop the habit of
writing dates as yyyy/mm/dd, and end each line in the list with "Enter"
(aka carriage return). This way, items will be sorted by year, within
the year by month, and within the month by day.

Rewrite the dates as yyyy/mm/dd, like this:

1965/06/22 ...
1966/03 ...
1975/09 ...

Now Sort will work as desired. The original list is A-Z (ascending), so
highlight the block of text, and select Z-A (descending). You'll get:

1975/09 ...
1966/03 ...
1965/06/22 ...

HTH
Wolf K.
 
W

Wolf K

Thanks for your suggestions, but I really don't care to use any 3rd
party stuff on my computer.
If you haven't got Microsoft Office, I'm afraid you'll have to. Or else
buy Office. Wordpad and Notepad just won't do what you want. They don't
Sort anything. I just tested Wordpad, to make sure. And Wordpad is
supposedly and improvement over Notepad!

If you have MS Office on your computer, use Word. It's unfortunate, but
a computer doesn't come with much usable software.

See my other post for step-by-step recipe for how to do what you want.

HTH,
Wolf K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

FireFox order of windows changes after reboot 1
file orderÉÉÉ 1
Sound Recorder in ZorinOS 7 0
Order of searching for device drivers 15
Sound Recorder 30
Problem Steps Recorder 4
SOLVED Add Flip 3D to Context Menu 10
Surprising Flip 1

Top