Welcome! Log In Create A New Profile

Advanced
SortParts.pl Re: LDMakeList V2.0
February 07, 2013 03:13PM
For those of you with perl on your PC, the below code allows you to make your own custom sort by using parts.xml. It will write parts.lst to the screen so must be directed to parts.lst. Simply change $Level1, $Level2 and $Level3 to alter your sorting style.

Run as: perl SortParts.pl > parts.lst

use XML::Simple;

# Sort by category, then filename, then description
$Level1="Category";
$Level2="Description";
$Level3="NameEntry";

sub CmpParts {
    # Sort at first level
    $c=$a->{$Level1} cmp $b->{$Level1};
    if ($c==0) {
	$c=$a->{$Level2} cmp $b->{$Level2};
	if ($c==0) {
	    $c=$a->{$Level3} cmp $b->{$Level3};
	}
    }
    return $c;
}

$xml=new XML::Simple;
$data=$xml->XMLin("parts.xml");
@PEArray = @{$data->{"FileEntry"}};

@PEArraySorted=sort CmpParts @PEArray;

foreach $P (@PEArraySorted) {
    print( sprintf("%-27s", $P->{"NameEntry"}).$P->{"Description"}."\n" );
}



Edited 4 time(s). Last edit at 2013-02-16 03:02PM by Tim Gould.
SubjectAuthorViewsPosted
LDMakeList V2.0 Tim Gould1070February 07, 2013 03:09PM
SortParts.pl Re: LDMakeList V2.0 Tim Gould418February 07, 2013 03:13PM
Re: LDMakeList V2.0 Max Martin Richter384February 07, 2013 03:37PM
Re: LDMakeList V2.0 Tim Gould385February 07, 2013 03:42PM
Re: LDMakeList V2.0 Max Martin Richter382February 07, 2013 03:54PM
Re: LDMakeList V2.0 Tim Gould387February 07, 2013 03:55PM
Re: LDMakeList V2.0 Travis Cobbs372February 07, 2013 04:24PM
Re: LDMakeList V2.0 Tim Gould365February 07, 2013 04:32PM
Re: LDMakeList V2.0 Willy Tschager356February 08, 2013 01:25AM
Re: LDMakeList V2.0 Tim Gould386February 08, 2013 01:59AM
Re: LDMakeList V2.0 Philippe Hurbain354February 08, 2013 04:55AM
Re: LDMakeList V2.0 Tim Gould384February 08, 2013 01:48PM
Re: LDMakeList V2.0 Michael Heidemann392February 09, 2013 12:58AM
Re: LDMakeList V2.0 Tim Gould442February 09, 2013 02:31PM
Re: LDMakeList V2.0 Michael Heidemann409February 09, 2013 03:12PM
Re: LDMakeList V2.0 Tim Gould416February 09, 2013 04:16PM
Re: LDMakeList V2.0 Michael Heidemann463February 10, 2013 05:21AM
Re: LDMakeList V2.0 Tim Gould406February 10, 2013 03:00PM
Re: LDMakeList V2.0 Michael Heidemann434February 11, 2013 08:28AM
Re: LDMakeList V2.0 Michael Heidemann400February 16, 2013 12:40AM
Re: LDMakeList V2.0 Michael Heidemann371February 16, 2013 03:27AM
Re: LDMakeList V2.0 Tim Gould404February 16, 2013 02:38PM
Re: LDMakeList V2.0 Michael Heidemann382February 16, 2013 03:38PM
Re: LDMakeList V2.0 Tim Gould394February 16, 2013 04:38PM
Re: LDMakeList V2.0 Michael Heidemann347February 17, 2013 05:46AM
Re: LDMakeList V2.0 Roland Melkert366February 16, 2013 03:50PM
Re: LDMakeList V2.0 Tim Gould420February 16, 2013 04:33PM
Re: LDMakeList V2.0 Michael Heidemann344February 17, 2013 06:19AM
Re: LDMakeList V2.0 Roland Melkert317February 17, 2013 09:33AM
Re: LDMakeList V2.0 Michael Heidemann313February 17, 2013 10:10AM
Re: LDMakeList V2.0 Tim Gould408February 17, 2013 01:49PM
Re: LDMakeList V2.0 Travis Cobbs396February 16, 2013 07:53PM
Re: LDMakeList V2.0 Tim Gould360February 17, 2013 01:44AM
Re: LDMakeList V2.0 Michael Heidemann342February 17, 2013 05:58AM
Re: LDMakeList V2.0 Tim Gould357February 17, 2013 01:35PM
Re: LDMakeList V2.0 Michael Heidemann340February 17, 2013 05:43AM
Re: LDMakeList V2.0 Roland Melkert299February 17, 2013 09:20AM
Re: LDMakeList V2.0 Michael Heidemann366February 17, 2013 09:53AM
Update Re: LDMakeList V2.01 Tim Gould392February 23, 2013 02:41PM
Re: Update Re: LDMakeList V2.01 Michael Heidemann456February 23, 2013 11:55PM
Re: LDMakeList V2.0 Michael Heidemann324September 06, 2013 01:26PM
Re: LDMakeList V2.13 Tim Gould346September 06, 2013 02:23PM
Re: LDMakeList V2.13 Michael Heidemann335September 06, 2013 02:33PM
Re: LDMakeList V2.13 Magnus Forsberg331September 08, 2013 05:22AM
Re: LDMakeList V2.13 Tim Gould303September 08, 2013 05:40AM
Re: LDMakeList V2.13 Michael Heidemann324September 08, 2013 06:50AM
Re: LDMakeList V2.13 Magnus Forsberg285September 08, 2013 07:06AM
Re: LDMakeList V2.13 Michael Heidemann515September 08, 2013 08:50AM
Re: LDMakeList V2.13 Tim Gould549September 08, 2013 07:28PM



Sorry, only registered users may post in this forum.

Click here to login