I have several thousand objects with a string property in a format "yyyy-MM-ddTHH:mm:ssZ". I want to sort these objects by time.
"yyyy-MM-ddTHH:mm:ssZ"
Are there any useful packages or scripts for this?
(Right now I'm just comparing individual numerical values and it seems like this is not very efficient and neat.)
You can use Time :: Local to convert the date to timestamp or one of Date :: modules from cpan. You can look this one to find out what is available.
, ( , , , , ).
, , . .
sort . .
sort
@sorted = sort @timestamps;
, perl "sort" "cmp".
, .
sub timeSort { my ($time) = ( shift =~ /\d{2}:\d{2}:\d{2}/ ); return $time; } my @sortedList = sort { timeSort($a) <=> timeSort($b) } @oldList;
Source: https://habr.com/ru/post/1737919/More articles:How to clear password field after login failure? - djangoHow to encapsulate helper functions (commonly used by apis) in OOP language like java? - javaMembership.GetUser () in TransactionScope throws TransactionPromotionException - c #Соглашения об именах Entity Framework для таблиц ссылок "многие-ко-многим" - sql-servernhibernate transaction and transactions abort spontaneously - nhibernateSubtracting months / years with boost :: posix_time :: ptime - c ++Using Visual Studio 2005 (32 bit) on a 64-bit Windows 7 machine - windows-7https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737922/set-a-text-from-a-java-object-with-new-lines-to-a-javascript-variable-in-jsp&usg=ALkJrhgRcmS2PYifa5w0BWMsdZeZXXozPwwhat's wrong here? associativity? assessment procedure? How to change the order? - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737924/whats-the-fastest-way-to-determine-if-a-file-adheres-to-a-particular-classs-nscoding-implementation&usg=ALkJrhi57hNiGih9xAwgPpxgxMHLADjTpAAll Articles