LDMakeList V2.0


SortParts.pl Re: LDMakeList V2.0
#2
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

Code:
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" );
}
Reply
« Next Oldest | Next Newest »



Messages In This Thread
LDMakeList V2.0 - by Tim Gould - 2013-02-07, 23:09
SortParts.pl Re: LDMakeList V2.0 - by Tim Gould - 2013-02-07, 23:13
Re: LDMakeList V2.0 - by Max Martin Richter - 2013-02-07, 23:37
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-07, 23:42
Re: LDMakeList V2.0 - by Max Martin Richter - 2013-02-07, 23:54
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-07, 23:55
Re: LDMakeList V2.0 - by Travis Cobbs - 2013-02-08, 0:24
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-08, 0:32
Re: LDMakeList V2.0 - by Willy Tschager - 2013-02-08, 9:25
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-08, 9:59
Re: LDMakeList V2.0 - by Philippe Hurbain - 2013-02-08, 12:55
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-08, 21:48
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-09, 8:58
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-09, 22:31
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-09, 23:12
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-10, 0:16
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-10, 13:21
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-10, 23:00
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-11, 16:28
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-16, 8:40
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-16, 11:27
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-16, 22:38
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-16, 23:38
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-17, 0:38
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-17, 13:46
Re: LDMakeList V2.0 - by Roland Melkert - 2013-02-16, 23:50
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-17, 0:33
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-17, 14:19
Re: LDMakeList V2.0 - by Roland Melkert - 2013-02-17, 17:33
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-17, 18:10
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-17, 21:49
Re: LDMakeList V2.0 - by Travis Cobbs - 2013-02-17, 3:53
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-17, 9:44
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-17, 13:58
Re: LDMakeList V2.0 - by Tim Gould - 2013-02-17, 21:35
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-17, 13:43
Re: LDMakeList V2.0 - by Roland Melkert - 2013-02-17, 17:20
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-02-17, 17:53
Update Re: LDMakeList V2.01 - by Tim Gould - 2013-02-23, 22:41
Re: LDMakeList V2.0 - by Michael Heidemann - 2013-09-06, 20:26
Re: LDMakeList V2.13 - by Tim Gould - 2013-09-06, 21:23
Re: LDMakeList V2.13 - by Michael Heidemann - 2013-09-06, 21:33
Re: LDMakeList V2.13 - by Magnus Forsberg - 2013-09-08, 12:22
Re: LDMakeList V2.13 - by Tim Gould - 2013-09-08, 12:40
Re: LDMakeList V2.13 - by Michael Heidemann - 2013-09-08, 13:50
Re: LDMakeList V2.13 - by Magnus Forsberg - 2013-09-08, 14:06
Re: LDMakeList V2.13 - by Michael Heidemann - 2013-09-08, 15:50
Re: LDMakeList V2.13 - by Tim Gould - 2013-09-09, 2:28

Forum Jump:


Users browsing this thread: 7 Guest(s)