Unstoppable Domains โ€” Expired Auctions

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

Spaceship Spaceship
Watch

DomainBELL

Three DecadesTop Member
Impact
1,089
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
it for sorting...
(unlimited - or 25k words at a time)

:wave:
~Patricia Kaehler - DomainBELL
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Is this for YOU to use as a tool? if so aren't there tools which are downloadable to do this already?
 
0
•••
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...)
 
0
•••
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
 
0
•••
PHP:
<?php

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

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

usort($array, 'cmp');

print_r($array);

?>


If the string you want to search are in a file, then:

PHP:
$array = file('filename.txt', FILE_IGNORE_NEW_LINE);
 
Last edited:
1
•••
Here is a version that displays a form to enter the words.

PHP:
<?php

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

function print_array(&$arr) {
    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 '
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>
';
?>
 
0
•••
thank you kindly...

I'll give that a try today...

Sincerely APPRECIATED...

~Patricia - DomainBELL

:blink:
 
0
•••
qbert220 -- Ian

Thanks for your help...
I sent you some NP$
(instead of PP)
Ribbon UP - giggle...
~Patricia - DomainBELL
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back