ports/75661: New Port: textproc/p5-Sort-Naturally - Sort lexically, but sort numeral parts numerically

Aaron Dalton aaron at daltons.ca
Thu Dec 30 16:20:27 UTC 2004


>Number:         75661
>Category:       ports
>Synopsis:       New Port: textproc/p5-Sort-Naturally - Sort lexically, but sort numeral parts numerically
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 30 16:20:26 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Aaron Dalton
>Release:        FreeBSD 5.2.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD chariss.finch.st 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #0: Wed Sep 29 21:39:19 MDT 2004 aaron at chariss.finch.st:/usr/src/sys/i386/compile/CHARISS i386


	
>Description:
This module exports two functions, nsort and ncmp; they are used in
implementing my idea of a "natural sorting" algorithm. Under natural
sorting, numeric substrings are compared numerically, and other
word-characters are compared lexically.

This is the way I define natural sorting:

    * Non-numeric word-character substrings are sorted lexically,
case-insensitively: "Foo" comes between "fish" and "fowl".
    * Numeric substrings are sorted numerically: "100" comes after "20",
not before.
    * \W substrings (neither words-characters nor digits) are ignored.
    * Our use of \w, \d, \D, and \W is locale-sensitive: Sort::Naturally
uses a use locale statement.
    * When comparing two strings, where a numeric substring in one place
is not up against a numeric substring in another, the non-numeric always
comes first. This is fudged by reading pretending that the lack of a
number substring has the value -1, like so:
    * The start of a string is exceptional: leading non-\W (non-word,
non-digit) components are are ignored, and numbers come before letters.
    * I define "numeric substring" just as sequences matching m/\d+/ --
scientific notation, commas, decimals, etc., are not seen. If your data
has thousands separators in numbers ("20,000 Leagues Under The Sea" or
"20.000 lieues sous les mers"), consider stripping them before feeding
them to nsort or ncmp.

WWW: http://search.cpan.org/dist/Sort-Naturally/
Author: Sean M. Burke <sburke at cpan.org>

- Aaron Dalton
aaron at daltons.ca


>How-To-Repeat:
	
>Fix:

	

--- submission.txt begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	p5-Sort-Naturally
#	p5-Sort-Naturally/Makefile
#	p5-Sort-Naturally/distinfo
#	p5-Sort-Naturally/pkg-descr
#	p5-Sort-Naturally/pkg-plist
#
echo c - p5-Sort-Naturally
mkdir -p p5-Sort-Naturally > /dev/null 2>&1
echo x - p5-Sort-Naturally/Makefile
sed 's/^X//' >p5-Sort-Naturally/Makefile << 'END-of-p5-Sort-Naturally/Makefile'
X# New ports collection makefile for:	p5-Sort-Naturally
X# Date created:				30 December 2004
X# Whom:					Aaron Dalton <aaron at daltons.ca>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	Sort-Naturally
XPORTVERSION=	1.02
XCATEGORIES=	textproc perl5
XMASTER_SITES=	${MASTER_SITE_PERL_CPAN}
XMASTER_SITE_SUBDIR=	Sort
XPKGNAMEPREFIX=	p5-
X
XMAINTAINER=	aaron at daltons.ca
XCOMMENT=	Sort lexically, but sort numeral parts numerically
X
XPERL_CONFIGURE=	yes
X
XMAN3=		Sort::Naturally.3
X
X.include <bsd.port.mk>
END-of-p5-Sort-Naturally/Makefile
echo x - p5-Sort-Naturally/distinfo
sed 's/^X//' >p5-Sort-Naturally/distinfo << 'END-of-p5-Sort-Naturally/distinfo'
XMD5 (Sort-Naturally-1.02.tar.gz) = a173f3f8f519ebae6e5e578e843f6e1c
XSIZE (Sort-Naturally-1.02.tar.gz) = 10357
END-of-p5-Sort-Naturally/distinfo
echo x - p5-Sort-Naturally/pkg-descr
sed 's/^X//' >p5-Sort-Naturally/pkg-descr << 'END-of-p5-Sort-Naturally/pkg-descr'
XThis module exports two functions, nsort and ncmp; they are used in 
Ximplementing my idea of a "natural sorting" algorithm. Under natural 
Xsorting, numeric substrings are compared numerically, and other 
Xword-characters are compared lexically.
X
XThis is the way I define natural sorting:
X
X    * Non-numeric word-character substrings are sorted lexically, 
Xcase-insensitively: "Foo" comes between "fish" and "fowl".
X    * Numeric substrings are sorted numerically: "100" comes after "20", 
Xnot before.
X    * \W substrings (neither words-characters nor digits) are ignored.
X    * Our use of \w, \d, \D, and \W is locale-sensitive: Sort::Naturally 
Xuses a use locale statement.
X    * When comparing two strings, where a numeric substring in one place 
Xis not up against a numeric substring in another, the non-numeric always 
Xcomes first. This is fudged by reading pretending that the lack of a 
Xnumber substring has the value -1, like so:
X    * The start of a string is exceptional: leading non-\W (non-word, 
Xnon-digit) components are are ignored, and numbers come before letters.
X    * I define "numeric substring" just as sequences matching m/\d+/ -- 
Xscientific notation, commas, decimals, etc., are not seen. If your data 
Xhas thousands separators in numbers ("20,000 Leagues Under The Sea" or 
X"20.000 lieues sous les mers"), consider stripping them before feeding 
Xthem to nsort or ncmp.
X
XWWW: http://search.cpan.org/dist/Sort-Naturally/
XAuthor: Sean M. Burke <sburke at cpan.org>
X
X- Aaron Dalton
Xaaron at daltons.ca
END-of-p5-Sort-Naturally/pkg-descr
echo x - p5-Sort-Naturally/pkg-plist
sed 's/^X//' >p5-Sort-Naturally/pkg-plist << 'END-of-p5-Sort-Naturally/pkg-plist'
X%%SITE_PERL%%/Sort/Naturally.pm
X%%SITE_PERL%%/%%PERL_ARCH%%/auto/Sort/Naturally/.packlist
X at dirrm %%SITE_PERL%%/%%PERL_ARCH%%/auto/Sort/Naturally
X at unexec rmdir %D/%%SITE_PERL%%/%%PERL_ARCH%%/auto/Sort 2>/dev/null || true
X at unexec rmdir %D/%%SITE_PERL%%/Sort 2>/dev/null || true
END-of-p5-Sort-Naturally/pkg-plist
exit
--- submission.txt ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list