The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> What is the best alphabetizer to sort lines and paragraphs of text on a page?, or if not alphabetize, randomize will also work
JRBobDobbs
post Feb 18 2010, 04:51 PM
Post #1


Member
***

Group: Members
Posts: 41
Joined: 2-November 09
Member No.: 10,212



Hello.

I am looking for an alphabetizer, something that will alphabetize various lines and paragraphs of text. A randomizer would also work. I have Googled "alphabetizer" but the only ones I could find were not what I need.

I will have paragraphs of text like so:

<a href="all paragraphs will start with ahref like this">title to be alphabetized</a>
<p>


As you can see, a standard alphabetizer will not work, because the first letters are part of the URL, and I want to sort by title. The alphabetizer would have to ignore the beginning of each entry starting from the opening <a href=" and ending at the ">

Additionally, I need an alphabetizer that will alphabetize entire paragraphs of text, not only lines of text. Because if it only works with lines, then since the <p> html code in the above example is on a separate line from the text above it, the alphabetizer treats it as a separate entry altogether. This wouldn't be a problem, except I have literally thousands of paragraphs to sort, so I don't want to have to manually input the <p> for each one.

I assume that it would be really quite simple, from a computer coding/making/technical/idon'tevenknowtheterm point of view, to create an alphabetizing program that could meet all my needs here. I assume that one already exists and that it is free, but I assume it is not too high in the Google pagerankings, as is often the case with the best free computer gadgets made by people who legitimately want to make everyone's life a little easier.

So... does anyone know of an awesome alphabetizer?! biggrin.gif

Thanks a lot in advance for any assistance you could offer.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies(1 - 15)
Darin McGrew
post Feb 18 2010, 05:35 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



I'd tackle this in two steps. First, I'd process the data so each "paragraph" is on a single line. Second, I'd sort them, starting with the first character after the <a href=...> tag.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 19 2010, 03:00 AM
Post #3


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



First, the word "alphabetizer" isn't used in computer science -- it's normally referred to as "sorting" (since it might or might not relate to [Roman] alphabet order).

Try looking for something like "sorting html paragraphs"...

Is this stuff in a text file? How many lines are there? Can't you just sort them by hand? If they are generated by some sort of program, it's probably easier to just change the program to output them in the desired order. More details would help, most particularly a URL.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 19 2010, 03:02 AM
Post #4


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(Darin McGrew @ Feb 19 2010, 07:35 AM) *

I'd tackle this in two steps. First, I'd process the data so each "paragraph" is on a single line. Second, I'd sort them, starting with the first character after the <a href=...> tag.


Yes, but your answer, Darin, is curiously reminiscent of a patent on a "software invention". It isn't actually the solution to anything, merely a slightly better specified statement of the problem. (So why not apply for a patent on it, then when someone else does the work, you get to collect the money. What a Wonderful World We Live In!)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
JRBobDobbs
post Feb 19 2010, 03:44 AM
Post #5


Member
***

Group: Members
Posts: 41
Joined: 2-November 09
Member No.: 10,212



QUOTE(Brian Chandler @ Feb 19 2010, 03:02 AM) *

QUOTE(Darin McGrew @ Feb 19 2010, 07:35 AM) *

I'd tackle this in two steps. First, I'd process the data so each "paragraph" is on a single line. Second, I'd sort them, starting with the first character after the <a href=...> tag.


Yes, but your answer, Darin, is curiously reminiscent of a patent on a "software invention". It isn't actually the solution to anything, merely a slightly better specified statement of the problem. (So why not apply for a patent on it, then when someone else does the work, you get to collect the money. What a Wonderful World We Live In!)

Hehe, to be honest that's what I was thinking, but you said it a lot better than I would have!

QUOTE(Brian Chandler @ Feb 19 2010, 03:00 AM) *

First, the word "alphabetizer" isn't used in computer science -- it's normally referred to as "sorting" (since it might or might not relate to [Roman] alphabet order).

Try looking for something like "sorting html paragraphs"...

Is this stuff in a text file? How many lines are there? Can't you just sort them by hand? If they are generated by some sort of program, it's probably easier to just change the program to output them in the desired order. More details would help, most particularly a URL.


Well as I said the number of lines is unfortunately in the (low) thousands, and as well I will need to re-sort the lists periodically thus I cannot just do it by hand each time. I generate the lists manually. Here is the link in question:

http://meta larchives.tran scix.co m/lin ks.html

Just eliminate all the spaces in that URL (I run advertising and it is bad if I get superfluous hits).

As you can see, it is not exactly "paragraphs" that I need to sort, because the <p> is on a separate line (I pressed ENTER). Really they are I guess 'text blocks'.

I am totally unaware of what the correct technical term is, so I thank you for telling me it is "sorting". I had tried that in Google, but the problem is that I just cannot find any good results on Google for what I'm looking for. I get a few ones for "alphabetizing" but they aren't good enough, and for example I get none when I type in "sorting html paragraphs" in quotation marks. I figured it would just be much easier to ask the question here (first I used the forum search function, of course).

One thing that has come to mind is that perhaps I could copy the list of 'text blocks' into a WYSIWYG html editor, choose the basic view and sort them there, then go back to the html view to retrieve the html? Would this work? (and if so, could you by chance recommend me a free WYSIWYG editor if you happen to know of a good one?)

This post has been edited by JRBobDobbs: Feb 19 2010, 03:49 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 19 2010, 07:24 AM
Post #6


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



CODE
<p><a href="http://thewhim.blogspot.com/2009/12/anti-cosmosis-black-mahapralaya-text.html">Anti-Cosmosis: Black Mahapralaya</a> (paper, by Nicola Masciandaro, 2009, presented at the Hideous Gnosis Black Metal Theory Symposium // from an arguably 'life-negating' or 'transcendental nihilist' perspective, discusses black metal as a means of realizing spiritually enlightening/liberating catharsis or Zen-like direct experience of reality) <span style="font-size:73%">[genre qualification; occultism & Satanism; psychology & ideology; religion & spirituality]</span>


Gosh, I thought I knew what "metal" means...

Anyway, are you saying you have a collection of several thousand paragraphs like the above, and you edit them entirely by hand?

First, I would not recommend WYSIWYG anything, since these programs normally regard themselves as "in charge". They will happily screw up your work if they "think" they are "improving" it.

The obvious way to do this is to keep the entries in a structured database (MySQL etc): with fields for the URL, the main text, annotations, keywords, whatever. Then not only can you present them in alphabetical order, but also selections etc. This is vastly easier to handle, once you have it set up.

You may be able to find a prebuilt application for handling this, but it's probably just as easy to write your own (or get it written: I would expect to take an evening to get the basic thing working, but these things do have a way of consuming the remainder of your life if you can't resist tinkering...)

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
JRBobDobbs
post Feb 19 2010, 12:57 PM
Post #7


Member
***

Group: Members
Posts: 41
Joined: 2-November 09
Member No.: 10,212



QUOTE(Brian Chandler @ Feb 19 2010, 07:24 AM) *

CODE
<p><a href="http://thewhim.blogspot.com/2009/12/anti-cosmosis-black-mahapralaya-text.html">Anti-Cosmosis: Black Mahapralaya</a> (paper, by Nicola Masciandaro, 2009, presented at the Hideous Gnosis Black Metal Theory Symposium // from an arguably 'life-negating' or 'transcendental nihilist' perspective, discusses black metal as a means of realizing spiritually enlightening/liberating catharsis or Zen-like direct experience of reality) <span style="font-size:73%">[genre qualification; occultism & Satanism; psychology & ideology; religion & spirituality]</span>


Gosh, I thought I knew what "metal" means...

Anyway, are you saying you have a collection of several thousand paragraphs like the above, and you edit them entirely by hand?

First, I would not recommend WYSIWYG anything, since these programs normally regard themselves as "in charge". They will happily screw up your work if they "think" they are "improving" it.

The obvious way to do this is to keep the entries in a structured database (MySQL etc): with fields for the URL, the main text, annotations, keywords, whatever. Then not only can you present them in alphabetical order, but also selections etc. This is vastly easier to handle, once you have it set up.

You may be able to find a prebuilt application for handling this, but it's probably just as easy to write your own (or get it written: I would expect to take an evening to get the basic thing working, but these things do have a way of consuming the remainder of your life if you can't resist tinkering...)

Thanks for all the help so far, Brian.

I have about 350 of those text blocks, but each one fits into multiple categories, so altogether I have a few thousand. It's time consuming because if I see a mistake in one then I have to change it in each place that it's listed. I have sometimes wondered if there isn't some sort of automated 'form' or 'directory' that I could use instead. However, I have no knowledge of any of those programs. Are you suggesting that MySQL would do it? Is MySQL what you would recommend to make a structured database for my purposes? I could certainly look into it...

On the other hand, though, let's suppose that MySQL is way too complicated for me to use. Couldn't I just do the WYSIWYG thing? It wouldn't be for the whole page, just the code of the text blocks. (I wouldn't publish any pages with it.)

Anyways, maybe it really would be beneficial in the long run to use a structured database. You seem to suggest MySQL is only one type of structured database... which type would you recommend for my purposes, exactly?

Also I should mention that I have a free hosting plan which doesn't support MySQL or PHP, and I'm in no position to get a paid plan for the time being.. do I absolutely need their "support"? (I do have one FTP account.)

This post has been edited by JRBobDobbs: Feb 19 2010, 01:01 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 19 2010, 02:08 PM
Post #8


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE
Also I should mention that I have a free hosting plan which doesn't support MySQL or PHP, and I'm in no position to get a paid plan for the time being.. do I absolutely need their "support"? (I do have one FTP account.)


I don't think you will find a "free" hosting service that includes a database server (but I might be wrong). In the end "free" means you will typically end up doing lots of manual fiddling around, and "free" is an excellent bargain if you value your own time at less than a dollar/euro/etc an hour. I use pair.com, who I recommend, but their cheapest option with MySQL is $20 / month, unless you're in US/Canada and take the http://pairlite.com option at $100/year (no phone support). I imagine it's possible to find cheaper.

If you use a database, you need one copy of each entry, with whatever classification info pertains to it. You can then display pages one for each Major Category, you can provide a search for other categories/keywords/etc. You can add things like user "voting", to promote the most popularly rated entries to the top, and whatever -- as in interplanetary travel, the sky's the limit!

SQL databases are sort of "standard" -- there are others, but MySQL (which is FLOSS software) is most widely offered.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Feb 19 2010, 04:29 PM
Post #9


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Another way to sort things is with a text editor, e.g. TextPad.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
JRBobDobbs
post Feb 20 2010, 12:20 AM
Post #10


Member
***

Group: Members
Posts: 41
Joined: 2-November 09
Member No.: 10,212



QUOTE(Christian J @ Feb 19 2010, 04:29 PM) *

Another way to sort things is with a text editor, e.g. TextPad.

I do not see what TextPad will accomplish...

QUOTE(Brian Chandler @ Feb 19 2010, 02:08 PM) *

QUOTE
Also I should mention that I have a free hosting plan which doesn't support MySQL or PHP, and I'm in no position to get a paid plan for the time being.. do I absolutely need their "support"? (I do have one FTP account.)

In the end "free" means you will typically end up doing lots of manual fiddling around, and "free" is an excellent bargain if you value your own time at less than a dollar/euro/etc an hour.

Although I agree, I cannot afford a paid plan, so at worst I will just leave it all unsorted. At the end of the day this sorting I want to do is just a touch-up - it would be really nice if it could happen, but if not people probably won't really notice it.

So far I have come up with this:

1. Copy the links from the webpage itself (so the HTML does not show)
2. Paste into OpenOffice word processor
3. Sort alphabetically
3. Copy them again from OpenOffice (still the HTML is not showing)
4. Paste into Nvu WYSIWYG editor in preview view
5. Go to Nvu source view and you will see the HTML
6. Copy this HTML and paste into web host file manager

I tried this with other stuff like Microsoft Works, Amaya WYSIWYG, etc., and it never worked except with this specific combination of programs. The only problem is that, although the links do come out sorted alphabetically, the HTML is not perfect:

<p><a
href="http://www.inter-disciplinary.net/ci/mmp/mmp1/floeckher%20paper.pdf">*beep*
Euphemisms: How Heavy Metal Lyrics Speak the Truth About War and
Oppression</a> (paper, by Richard J.
Floeckher, 2008, presented at
the first Heavy Fundamentalisms: Music, Metal and Politics
conference) [culture; psychology &amp; ideology] </p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/moorpaper.pdf">Dissonance
and Dissidents</a> (paper, by Sarha
Moore, 2009, presented at the
second Heavy Fundamentalisms: Music, Metal and Politics conference //
discusses the deliberate and extensive use of the semitone note just
above the key-note in metal) [culture; psychology &amp; ideology;
technical] </p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/mckinnonpaper.pdf">Louder
than Hell: Power Volume and the Brain</a>
(paper, by Colin A.
McKinnon, 2009, presented at the second Heavy Fundamentalisms: Music,
Metal and Politics conference) [culture; psychology &amp; ideology;
studies &amp; experiments] </p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/Lucas-paper.pdf">White
Power, Black Metal and Me: Reflections on Composing the Nation</a>
(paper, by Caroline Lucas, 2009, presented at the second Heavy
Fundamentalisms: Music, Metal and Politics conference) [genre
qualification; national/regional history &amp; identity; prejudice
&amp;
education/activism; psychology &amp; ideology] </p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/heldenpaper.pdf">Scandinavian
Metal Attack: The Power of Northern Europe in Extreme Metal</a>
(paper, by Imke von Helden, 2009, presented at the second Heavy
Fundamentalisms: Music, Metal and Politics conference)
[national/regional history &amp; identity; psychoogy &amp;
ideology] </p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/frandsenpaper.pdf">Living
for Music, Dying for Life - The Self Destructive Lifestyle in Heavy
Metal Culture</a> (paper, by Daniel
Frandsen, 2009, presented at the
second Heavy Fundamentalisms: Music, Metal and Politics conference)
[culture; psychology &amp; ideology] </p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/gafarovpaper.pdf">Metal
Community and Aesthetics of Identity</a>
(paper, by Igor Gafarov,
2009, presented at the second Heavy Fundamentalisms: Music, Metal and
Politics conference) [culture; psychology &amp; ideology]</p>
<p><a
href="http://www.inter-disciplinary.net/wp-content/uploads/2009/10/rhillpaper.pdf">&ldquo;I&rsquo;m
a Metal head&rdquo;: The Representation of Women Letter Writers in
Kerrang! Magazine</a> (paper, by
Rosemary Hill, 2009, presented at
the second Heavy Fundamentalisms: Music, Metal and Politics
conference) [culture; psychology &amp; ideology] </p>

As you can see, it breaks the lines at odd intervals for no apparent reason (does not correspond with the word-wrapping at end of each line on OpenOffice). And I will need to add a bit of HTML like <span font size...>, however that can be done quite easily with "Find and Replace" features on Notepad or anything else.

I am wondering, will this weird kind of line breaks affect anything negatively? Will it confuse the browser and make the page load slower? Will it show differently on some browsers than on other browsers? Perhaps is there a program or internet service I could use to "verify" my css and fix it up?

Thanks..

This post has been edited by JRBobDobbs: Feb 20 2010, 12:21 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 20 2010, 01:46 AM
Post #11


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



No. Whitespace is whitespace. Space or linebreak matters not.

The format is different above from the page I looked at. The text editor I use has an internal makro/scripting language that's quite useful. I started to look at your paragraphs just for fun. The only problem I had was what to do with all the unmatched P tags that looked somewhat random. But in this sample you use both start and closing tags which makes it much simpler (I could let the script remove them, sort lines and then put each line in a para again).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 20 2010, 01:50 AM
Post #12


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



QUOTE(JRBobDobbs @ Feb 20 2010, 06:20 AM) *

Perhaps is there a program or internet service I could use to "verify" my css and fix it up?


How could I miss that? wub.gif

HTML validators
http://htmlhelp.com/tools/validator/
http://validator.w3.org/
CSS checker
http://jigsaw.w3.org/css-validator/
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
JRBobDobbs
post Feb 20 2010, 02:02 AM
Post #13


Member
***

Group: Members
Posts: 41
Joined: 2-November 09
Member No.: 10,212



QUOTE(pandy @ Feb 20 2010, 01:46 AM) *

No. Whitespace is whitespace. Space or linebreak matters not.

The format is different above from the page I looked at. The text editor I use has an internal makro/scripting language that's quite useful. I started to look at your paragraphs just for fun. The only problem I had was what to do with all the unmatched P tags that looked somewhat random. But in this sample you use both start and closing tags which makes it much simpler (I could let the script remove them, sort lines and then put each line in a para again).

Hi Pandy.

Are you saying you could remove the <p> tags and then sort the lines by the link title even though the link URL precedes the link title? If so, then I'd be much obliged to learn what is the name of the program you use.

As for not closing the <p> tags, yeah, I never have.. I just don't see any use. Maybe if I were doing more complex HTML maneuvers it would be more essential, but personally I don't think I need to close them (correct me if I'm wrong).

QUOTE(pandy @ Feb 20 2010, 01:50 AM) *

QUOTE(JRBobDobbs @ Feb 20 2010, 06:20 AM) *

Perhaps is there a program or internet service I could use to "verify" my css and fix it up?


How could I miss that? wub.gif

HTML validators
http://htmlhelp.com/tools/validator/
http://validator.w3.org/
CSS checker
http://jigsaw.w3.org/css-validator/

Oh, what I meant is for a program or website that can actually clean up my html, like physically alter it, so that the weird line breaks are removed (and hopefully it would leave everything else alone). I do not believe those sites do that, although the sites have some things on them I don't really understand, so maybe I'm just not seeing it...

This post has been edited by JRBobDobbs: Feb 20 2010, 02:02 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Feb 20 2010, 03:16 AM
Post #14


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE
Oh, what I meant is for a program or website that can actually clean up my html, like physically alter it, so that the weird line breaks are removed (and hopefully it would leave everything else alone).


You're trying to use the more modern notion of what computers do, which is to provide an ersatz version of a hand tool, such as a pencil, which is never faster, but usually prettier.

Well, what you _really_ need is a set of tools, so you can go back to what computers were for two or three decades ago, which was automating tasks according to a user specification. Probably awk would do your job perfectly, once you had wrestled with its syntax. Once you can write a program for the tasks you have to do, things start happening faster and faster.

If the situation of your time being worth less than a dollar an hour is temporary, one budget free option would be to install a LAMP stack on your computer at home, and run a database system, then copy the (static) output pages from it to your remote "beer-free" server.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
JRBobDobbs
post Feb 20 2010, 03:35 AM
Post #15


Member
***

Group: Members
Posts: 41
Joined: 2-November 09
Member No.: 10,212



QUOTE(Brian Chandler @ Feb 20 2010, 03:16 AM) *

QUOTE
Oh, what I meant is for a program or website that can actually clean up my html, like physically alter it, so that the weird line breaks are removed (and hopefully it would leave everything else alone).

If the situation of your time being worth less than a dollar an hour is temporary,

Actually it is the other way around - I value life so much that I do not work only for money, hence I have meager finances. Or in other words I thought my time is worth $1000/hr, and refused to work for less! Heh, but as I said, if this sorting thing cannot be done easily then I will forgo it altogether.

I will look into your suggestions, thank you.

This post has been edited by JRBobDobbs: Feb 20 2010, 03:37 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Feb 20 2010, 05:29 PM
Post #16


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



QUOTE(JRBobDobbs @ Feb 20 2010, 08:02 AM) *

Are you saying you could remove the <p> tags and then sort the lines by the link title even though the link URL precedes the link title? If so, then I'd be much obliged to learn what is the name of the program you use.
believe those sites do that, although the sites have some things on them I don't really understand, so maybe I'm just not seeing it...



No, what I did was this. First I made the script find all start tags for A and temporarily move them to behind the link text, so it looked like this.

Link Text<a href=""></a>

Then after sorting the lines the script moved them back again.

If it always was a link per paragraph and no other links, extra P tags or other HTML elements mixed among the paragraphs we want, it would be quite simple. Fist I'd have the script remove all <p> and </p> (if there are any) then do the above and finish off by wrapping all lines in paras again. But since there are other elements it becomes complicated. We don't want to sort them too.

But that's with my text editor. With other scripting languages there may be other ways.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 07:10 PM