NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Script to Sort List of Words by Character Length...

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 03-23-2010, 09:57 AM THREAD STARTER               #1 (permalink)
DNOA Founding Member
 
DomainBELL's Avatar
Join Date: Feb 2006
Location: Ohio - USA
Posts: 1,292
DomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant future
 

Approved Contest Holder
Approved Contest Holder
Save The Children Save The Children Special Olympics 9/11/01 :: Never Forget 9/11/01 :: Never Forget Parkinson's Disease Special Olympics Ethan Allen Fund

Wanted Script to Sort List of Words by Character Length...


Hi There...

Anyone know of an open source script
(php) that will do the following:

Take a list of words that I copy paste
into it - and reorganize them by
character length -- from least to most...

Where can I find that ??

Or are you a php script whiz and want
to whip it up - for me to test...
($5.usd via PayPal - if you write it
and it works the way I want it to...
smile)

NOTE:
Needs to be unlimited in the amount
of words able to be copy pasted into
????: NamePros.com http://www.namepros.com/programming/646489-script-sort-list-words-character-length.html
it for sorting...
(unlimited - or 25k words at a time)


~Patricia Kaehler - DomainBELL
__________________
VeryFastCash.com ------ For Sale Offers Considered..
What's NEW with me... My Whats New Section - BLOG DomainBELL.com/WhatsNew/ -- Twitter: DomainBELL
DomainBELL is offline   Reply With Quote
Old 03-23-2010, 01:53 PM   #2 (permalink)
Senior Member
 
SeanPreston's Avatar
Join Date: Nov 2005
Location: UK
Posts: 1,280
SeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud ofSeanPreston has much to be proud of
 


Protect Our Planet Child Abuse Marrow Donor Program Animal Rescue
Is this for YOU to use as a tool? if so aren't there tools which are downloadable to do this already?
SeanPreston is offline   Reply With Quote
Old 03-23-2010, 02:34 PM   #3 (permalink)
Senior Member
 
nasaboy007's Avatar
Join Date: Jul 2005
Location: NJ
Posts: 1,219
nasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud ofnasaboy007 has much to be proud of
 



I'm not a linux user, but I found that you can do this in one linux command:

cat $@ | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $0}'

To be honest, no idea how it works (no linux experience), but maybe some of the more linux-savvy NPers can explain how to use it / what it does.

Of course, unless you have linux installed, you'd have to set up a virtual machine or something (which may be more effort than it's worth...)
nasaboy007 is offline   Reply With Quote
Old 03-23-2010, 03:22 PM THREAD STARTER               #4 (permalink)
DNOA Founding Member
 
DomainBELL's Avatar
Join Date: Feb 2006
Location: Ohio - USA
Posts: 1,292
DomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant future
 

Approved Contest Holder
Approved Contest Holder
Save The Children Save The Children Special Olympics 9/11/01 :: Never Forget 9/11/01 :: Never Forget Parkinson's Disease Special Olympics Ethan Allen Fund
thanks for the responses...

BTW I always do SEARCH first...
Or I wouldn't have bothered to post the question...

Anyone know someone that can whip out a quick php script to do this...

I'm searching for the name of an NPer that used to write scripts for me
all the time... I think he was in Arizona... I can't for the life of me
find his info... grrrr....

~Patricia
__________________
VeryFastCash.com ------ For Sale Offers Considered..
What's NEW with me... My Whats New Section - BLOG DomainBELL.com/WhatsNew/ -- Twitter: DomainBELL
DomainBELL is offline   Reply With Quote
Old 03-23-2010, 04:02 PM   #5 (permalink)
NamePros Regular
 
qbert220's Avatar
Join Date: Jul 2007
Location: UK
Posts: 394
qbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to behold
 


Protect Our Planet
PHP Code:
<?php

$array 
= array (
'anteater',
'bear',
'cheetah',
);

function 
cmp($a$b) {
    return 
strlen($a) - strlen($b);
}

usort($array'cmp');

print_r($array);

?>

????: NamePros.com http://www.namepros.com/showthread.php?t=646489
If the string you want to search are in a file, then:

PHP Code:
$array file('filename.txt'FILE_IGNORE_NEW_LINE); 
Last edited by qbert220; 03-24-2010 at 02:23 AM.
qbert220 is offline   Reply With Quote
Old 03-24-2010, 02:31 AM   #6 (permalink)
NamePros Regular
 
qbert220's Avatar
Join Date: Jul 2007
Location: UK
Posts: 394
qbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to beholdqbert220 is a splendid one to behold
 


Protect Our Planet
Here is a version that displays a form to enter the words.

PHP Code:
<?php

function cmp($a$b) {
    return 
strlen($a) - strlen($b);
}

function 
print_array(&$arr) {
????: NamePros.com http://www.namepros.com/showthread.php?t=646489
    echo 
"<pre>";
    foreach (
$arr as $val) {
        echo 
htmlentities($val)."\n";
    }
    echo 
"</pre>";
}

echo 
'<html>
<head>
<title>Length Sorter</title>
</head>
<body>
'
;

if (isset(
$_POST['text'])) {
    
$text preg_split('/\s+/'trim($_POST['text']));
    
    
usort($text'cmp');

    echo 
"<hr>After sorting:<br>\n";
    
print_array($text);
    echo 
"<hr>\n";
}

echo 
'
????: NamePros.com http://www.namepros.com/showthread.php?t=646489
Enter items below, one per line:
<form method="POST" action="'
.$_SERVER['PHP_SELF'].'">
<textarea name="text" rows="10" cols="20">
</textarea>
<br>
<input type="submit" name="Sort">
</form>
</body>
</html>
'
;
?>
qbert220 is offline   Reply With Quote
Old 03-24-2010, 08:47 AM THREAD STARTER               #7 (permalink)
DNOA Founding Member
 
DomainBELL's Avatar
Join Date: Feb 2006
Location: Ohio - USA
Posts: 1,292
DomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant future
 

Approved Contest Holder
Approved Contest Holder
Save The Children Save The Children Special Olympics 9/11/01 :: Never Forget 9/11/01 :: Never Forget Parkinson's Disease Special Olympics Ethan Allen Fund
thank you kindly...

I'll give that a try today...

Sincerely APPRECIATED...

~Patricia - DomainBELL

__________________
VeryFastCash.com ------ For Sale Offers Considered..
What's NEW with me... My Whats New Section - BLOG DomainBELL.com/WhatsNew/ -- Twitter: DomainBELL
DomainBELL is offline   Reply With Quote
Old 03-25-2010, 08:57 AM THREAD STARTER               #8 (permalink)
DNOA Founding Member
 
DomainBELL's Avatar
Join Date: Feb 2006
Location: Ohio - USA
Posts: 1,292
DomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant futureDomainBELL has a brilliant future
 

Approved Contest Holder
Approved Contest Holder
Save The Children Save The Children Special Olympics 9/11/01 :: Never Forget 9/11/01 :: Never Forget Parkinson's Disease Special Olympics Ethan Allen Fund
qbert220 -- Ian

Thanks for your help...
I sent you some NP$
(instead of PP)
Ribbon UP - giggle...
~Patricia - DomainBELL
__________________
VeryFastCash.com ------ For Sale Offers Considered..
What's NEW with me... My Whats New Section - BLOG DomainBELL.com/WhatsNew/ -- Twitter: DomainBELL
DomainBELL is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:36 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger