sorting

How do I sort a directory by time, and display the last four image files matching a pattern with php?

I have a directory that will be getting updated frequently, I want to display the last four images files uploaded, which match a certain pattern, on my php page. Is this possible without having to perform a sort on every single image within the directory? Many thanks! ...

Sorting by dates (including nil) with NSFetchedResultsController

In my NSFetchedResultsController, I set a sortDescriptor that sorts based on the date property of my managed objects. The problem that I have encountered (along with several others according to Google) is that nil values are sorted at the earliest end rather than the latest end of the date spectrum. I want my list to be sorted earliest...

Scheme sorting a list

Okay so I am trying to take in a list and sort it from greatest to smallest. Example: > (maxheap (list 5 6 2 1 18 7)) ;output: > (18 7 6 5 2 1) So here's what I got so far: (define (mkmaxheap heaplist) (let ((max (mymax(heaplist)))) ;mymax is a func that returns max number, it works (let (( head (car heaplist)) (tail (cdr he...

How do I sort strings that contain numbers in Java

I want to sort a String that has nr. How do I do that? Lets say my integers are Class2 "3" "4" "1" in main I do class2.Sort(); Thanks in Advance. ...

XSLT: use parameters in xls:sort attributes (dynamic sorting)

How do I apply a parameter to a select and order attribute in a xsl:sort element? I'ld like to do this dynamic with PHP with something like this: $xsl = new XSLTProcessor(); $xslDoc = new DOMDocument(); $xslDoc->load( $this->_xslFilePath ); $xsl->importStyleSheet( $xslDoc ); $xsl->setParameter( '', 'sortBy', 'viewCount' ); $xsl->setPar...

Tail-recursive merge sort in OCaml

Hello world! I’m trying to implement a tail-recursive list-sorting function in OCaml, and I’ve come up with the following code: let tailrec_merge_sort l = let split l = let rec _split source left right = match source with | [] -> (left, right) | head :: tail -> _split tail right (head :: left) in _spli...

What sorting algorithm is this?

Update: OK I see it's a bubble sort, but is it less efficient because it doesn't stop when there's no swap on a particular run? It runs until first is null. Hi, I have a sorting algorithm as follows. My question is, which sorting algorithm is this? I thought it was bubble sort, but it does not do multiple runs. Any idea? Thanks! //sort...

How should I do custom sort in Python 3?

In Python 2.x, I could pass custom function to sorted and .sort functions >>> x=['kar','htar','har','ar'] >>> >>> sorted(x) ['ar', 'har', 'htar', 'kar'] >>> >>> sorted(x,cmp=customsort) ['kar', 'htar', 'har', 'ar'] Because, in My language, consonents are comes with this order "k","kh",....,"ht",..."h",...,"a" But In Python 3.x, lo...

How to read a PS file in reverse order?

I have a PS file to be read in reverse order and process accordingly. Do we have a way to mention to read the file in reverse order in FD in COBOL module? OR do we have something to achieve the same using SORT? Note: Reading the records into a buffer (array) and using it in reverse order would be the first idea that comes to mind but th...

How to sort HashSet() function data in sequence?

I am new to Java, the function I would like to perform is to load a series of data from a file, into my hashSet() function. the problem is, I able to enter all the data in sequence, but I can't retrieve it out in sequence base on the account name in the file. Can anyone help? below is my code: public Set retrieveHistory(){ Se...

How can I do a multi level parent-child sort using Linq?

How can I do a multi-level parent-child sort using Linq if I have a table structure like the one below: [Table: Sections] Id Seq Name ParentSectionId 1 1 TOP NULL 2 1 AAAA 1 3 2 SSSS 1 4 3 DDDD 1 5 1 SectionA1 2 6 2 SectionA2 2 7 1 ...

How to sort an arraylist of objects by a property?

Lets say you have an arraylist of HockeyPlayer objects. How could you sort that if they all have a variable "int goalsScored". How could you sort them by goalsScored? ...

Excel function advanced filter

I have a list of sales people and a list of their sale revenues in two separate columns. How do I use an advanced filter or other sorting means to find the max of the sale revenue column and then have the formula output be the corresponding sales person? ...

How to quickly re-sort a MySQL table by one of the columns?

What are the most efficient SQL queries that would take an existing MySQL table and re-sort it by one of the columns? Not a selection, but the whole table should be sorted by one column. Somehow using a temporary table, I guess, but what's the best way? ...

Handling large (object) datasets with PHP

I am currently working on a project that extensively relies on the EAV model. Both entities as their attributes are individually represented by a model, sometimes extending other models (or at least, base models). This has worked quite well so far since most areas of the application only rely on filtered sets of entities, and not the en...

Sort/Group XML data with PHP?

I'm trying to make a page using data from the discogs.com (XML)-API. i've been parsing it with simpleXML and it's working pretty well but there is some things i'm not sure how to do. Here is part of the XML: <releases> <release id="1468764" status="Accepted" type="Main"> <title>Versions</title> <format>12", EP</format> <l...

Why does sorting a GridView by more than one column only apply the order to the last term?

I've spent a good portion of my day fighting with GridView.Sort(). Nothing I did seemed to make it behave the way I would have expected. It wasn't until a coworker told me that within the expression you can specify the sort order for each term (except for the last one, apparently). What is the purpose of supplying a sort direction if ...

Sorting a file with 55K rows and varying Columns

Hi I want to find a programmatic solution using C++. I have a 900 files each of 27MB size. (just to inform about the enormity ). Each file has 55K rows and Varying columns. But the header indicates the columns I want to sort the rows in an order w.r.t to a Column Value. I wrote the sorting algorithm for this (definitely my newbie at...

Disk Search / Sort Algorithm

Given a Range of numbers say 1 to 10,000, Input is in random order. Constraint: At any point only 1000 numbers can be loaded to memory. Assumption: Assuming unique numbers. I propose the following efficient , "When-Required-sort Algorithm". We write the numbers into files which are designated to hold particular range of numbers. Fo...

Groovy sorting string asc

How to sort string names in array on ascending order . I tried sort method but it fails to sort on name basis . def words = ["orange", "blue", "apple", "violet", "green"] I need to achieve like this : ["apple", "blue", "green", "orange", "violet" ] thanks in advance. ...