Sponsored Content
Special Forums UNIX and Linux Applications Matlab (more generally: sorting data by date) Post 302327746 by jim mcnamara on Monday 22nd of June 2009 01:34:57 PM
Old 06-22-2009
All you care about is the mm part.

Programatically I would transform the date column in the array, to a 'season value' before doing any sorting.

Create a vector (assuming zero based) S with 12 elements s[0..2] == 0 (Spring),
s[3..5] == 1 (Summer) and so on.

For each row in your array, get the mm substring from the date. Convert the mm to an integer say i, replace the date value in the column with s[i]. Use a length(column) to see if the year 2000 problem exists.

If you sort numerically on the transformed date column, you get seasonal order. You can also preserve the date by adding another column to the array, transforming into it, then sorting.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sorting on date

I have a file where dates in the form mm/dd/yyyy is the first field. How do I sort the file by the date field? Thanks, Duckman (6 Replies)
Discussion started by: Duckman
6 Replies

2. UNIX for Dummies Questions & Answers

date sorting

Hi at all, I have to sort a log file on timestamp field. That's field is the third! a log file sample..... 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:23|0.3.8 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:16|0.3.8 1|EVTVOD-1-20060709_000614|2006/07/09-0:11:20|0.3.8... (3 Replies)
Discussion started by: nmilella
3 Replies

3. Shell Programming and Scripting

Sorting a date coulumn

Hi All, I have a file say abc.txt with the below data. 1234 876S 01Mar2007 foo 1244 65DF 19Jan2007 boo 9924 234K 01Jan2006 koo 8866 8FGH 12Feb1999 roo 7777 ASDF 13May2007 soo I need this file to be in sorted order depending on the date field. e.g 8866 8FGH 12Feb1999 roo... (2 Replies)
Discussion started by: rinku11
2 Replies

4. Shell Programming and Scripting

Date Sorting

Hi, I have a list of files that take on the format ABCDE_yymmdd and wish to sort them in ascending date order. I can't use the unix time stamp for the file as this could possibly be different from the date given in the file name. Does anyone know of any way this can be done using unix shell... (14 Replies)
Discussion started by: LiquidChild
14 Replies

5. UNIX and Linux Applications

Importing data's from cadence to MATLAB

hello, debashish here. i am working with 6 bit flash ADC design. So for calculation of INL and DNL ,i have to import data from cadence to MATLAB . Can anybody help me out:confused: (1 Reply)
Discussion started by: DEBASHISH DASH
1 Replies

6. Shell Programming and Scripting

Sorting the data with date

Hi, PFB the data: C_Random_130417 Java_Random_130518 Perl_Random_120519 Perl_Random_120528 so the values are ending with year,i.e.,130417 i want to sort the values with date. i want the output like this: Perl_Random_120519 Perl_Random_120528 C_Random_130417 Java_Random_130518 can... (5 Replies)
Discussion started by: arindam guha
5 Replies

7. Shell Programming and Scripting

Sorting by date

I am trying to sort by two columns. The first column in an ID, the second is a date in the form yyyy-mm-dd. I need to sort by the ID column, then in ascending order for the date column (earliest date to most recent date compared to today). Input data: 012-abc 2012-04-25 ... (3 Replies)
Discussion started by: mollydog11
3 Replies

8. Shell Programming and Scripting

Sorting data file by date and time

Hello. Sorting data file by date and time with the following issues: Date is in the following format m/d/yyyy, no leading zeros Time is in the following format h:m:s AM/PM, no leading zeros Any ideas on how to sort data when the above issues? Could the date/time be converted inline to... (5 Replies)
Discussion started by: JimBurns
5 Replies

9. UNIX for Dummies Questions & Answers

Plz Help in sorting the data on date basis

I have file having below data 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493 01-JUL-13... (2 Replies)
Discussion started by: ranabhavish
2 Replies

10. Shell Programming and Scripting

Plz Help in sorting the data on date basis

I have file a.txt having below data cat a.txt 01-MAY-13 2.38.11.00.100089 IN 4512 0000741881 01-JUN-13 2.38.11.00.100089 IN 1514 0000764631 01-NOV-13 2.38.11.00.100089 IN 1514 0000856571 01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531 01-JUN-13 2.38.19.00.100000 IN 2698 0000764493... (5 Replies)
Discussion started by: ranabhavish
5 Replies
Class::DBI::Plugin::RetrieveAll(3pm)			User Contributed Perl Documentation		      Class::DBI::Plugin::RetrieveAll(3pm)

NAME
Class::DBI::Plugin::RetrieveAll - more complex retrieve_all() for Class::DBI SYNOPSIS
use base 'Class::DBI'; use Class::DBI::Plugin::RetrieveAll; my @by_date = My::Class->retrieve_all_sorted_by("date"); # or __PACKAGE__->retrieve_all_sort_field('date'); my @by_date = My::Class->retrieve_all; DESCRIPTION
This is a simple plugin to a Class::DBI subclass that allows for simple sorting of the results of a retrieve_all(). There are two main ways to use this. Firstly, we create a new method 'retrieve_all_sorted_by' which takes an argument of how to sort. We also add a method for 'retrieve_all_sort_field' that sets a default field that any retrieve_all() will use for sorting. METHODS
retrieve_all_sorted_by my @by_date = My::Class->retrieve_all_sorted_by("date"); This method will be exported into the calling class, and allows for retrieving all the objects of the class, sorted by the given column. The argument given will be passed straight through to the database 'as is', and is not checked in any way, so an error here will usually in an error from the database, rather than Class::DBI itself. This makes it possible to pass more complex ORDER BY clauses through: my @by_date = My::Class->retrieve_all_sorted_by("date DESC, reference_no"); retrieve_all_sort_field __PACKAGE__->retrieve_all_sort_field('date'); This method changes the default retrieve_all() in the Class to be auto-sorted by the field given. Again this will be passed through directly, so you can have complex ORDER BY clauses. AUTHOR
Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Class-DBI-Plugin-RetrieveAll@rt.cpan.org COPYRIGHT and LICENSE Copyright (C) 2004-2006 Kasei. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2006-01-16 Class::DBI::Plugin::RetrieveAll(3pm)
All times are GMT -4. The time now is 07:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy