Hi Byron. I have the sorting algorithm that works on arrays at this point. My question is even more basic. How do I create a @data (or even a %data) like you have below, from a result set?
Emily > -----Original Message----- > From: Byron Young [mailto:[EMAIL PROTECTED] > Sent: Friday, June 13, 2008 3:09 PM > To: DBIx::Class user and developer list > Subject: RE: [Dbix-class] natural sort by column > > Hi Emily, > > This is untested and inelegant, but might get you closer to what you want: > > my @data = $c->model('DB::MyModel')->search(...); > > @data = sort { $a->sort_column =~ /^(.*)(\d*)$/; > my $a_prefix = $1; my $a_suffix = $2; > $b->sort_column =~ /^(.*)(\d*)$/; > my $b_prefix = $1; my $b_suffix = $2; > $a_prefix cmp $b_prefix || > $a_suffix <=> $b_suffix } @data; > > > Byron > > > > > From: Emily Heureux [mailto:[EMAIL PROTECTED] > Sent: Friday, June 13, 2008 2:47 PM > To: 'DBIx::Class user and developer list' > Subject: [Dbix-class] natural sort by column > > Ok, I have tried to accomplish my 'natural' sort in mysql, template > toolkit, and in perl to no avail. I have a result set returned by using > search like this: > > $rs = $c->model('DB::TableName')->search(...); > > I have a 'natural sort' function in perl that takes and returns an array > sorted the way a human would sort (john10 would come AFTER john2, etc) but > how do I get my $rs or even $col = $rs->get_column('column name') into a > hash I can use from within perl? > > -Emily > > > > > _______________________________________________ > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class > IRC: irc.perl.org#dbix-class > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ > Searchable Archive: http://www.grokbase.com/group/dbix- > [EMAIL PROTECTED] _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]
