sorting

Problem in sorting xml in XSLT 2.0 any ideas?

Hello I am trying to sort my xml by number of occurence of element 'answer' with attribute 'id' and get simply summary. <person id="1"> <answer id="A"/> <answer id="B"/> </person> <person id="2"> <answer id="A"/> <answer id="C"/> </person> <person id="3"> <answer id="C"/> </person> I want simply summary text on output: A = 2...

Python sort parallel arrays in place?

Is there an easy (meaning without rolling one's own sorting function) way to sort parallel lists without unnecessary copying in Python? For example: foo = range(5) bar = range(5, 0, -1) parallelSort(bar, foo) print foo # [4,3,2,1,0] print bar # [1,2,3,4,5] I've seen the examples using zip but it seems silly to copy all your data from...

Redirecting paginator->sort to the first page in Cakephp

How do I do a paginator sort and also specify it to go to the first page: echo $paginator->sort('Make', 'Car.make'); If you're on page 6 and want to sort the list by car make. It sorts the list but puts you on page 6 of the sorted list. When someone clicks on the sort by "make" button, I want the paginator to take them to page 1 of th...

Hibernate Computed Criteria Order

I have an Oracle XMLType column that stores the various language specific strings. I need to construct a Hibernate criteria that orders on this column. In order to do this, I need to extract the value with an Oracle function. This criteria is generated automatically by code I have written but I cannot, for the life of me, figure out how ...

How to sort the row contents on table cell by using date

Hi i am new to iphone application development.i am developing RSS feed Reader it has number of different RSS feeds. In my application (XML parsing), i want to display the content of the row on cell for particular date and with their corresponding title, description (in my application, i am using three labels for displaying title, da...

Program to help sort files

Hey there I'm going through a lot of computers and a lot of data here and there. I'm moving it all to a server so everybody has access to it. There i have a folder for each computer. But a lot of the data is the same. Is there any program to help me combine the data that is the same ? It hell trying to do this manually. Basically i wa...

Access SQL Query Help

Hi Everyone. I have a query in which I need to perform using three entities listed below: LU_AppName SDB_AppHistory SDB_Session LU_AppName has field APPNAM, SDB_AppHistory has the field STARTTIME which is date/time and also SDB_Session has field DURATION. I need to run an SQL query to show me Citrix APPLICATIONS which have not been...

How can i sort an XDocument by attribute

I have a Xml <Users> <User Name="Z"/> <User Name="D"/> <User Name="A"/> </User> I want to sort that by Name. I load that xml using XDocument. How can i view that xml sorted by Name. ...

Sort a collection of objects by number (highest first) then by letter (alphabetical)

I'm building a widget to show medal counts for the Olympics. I have a collection of "country" objects, where each has a "name" attribute, and "gold", "silver", "bronze" for medal counts. List should be sorted: 1. First by total medal count 2. If same medals, sub-sort by type (gold > silver > bronze, ie. two golds > 1 gold + 1 silver) 3....

Do any real-world CPUs not use IEEE 754?

I'm optimizing a sorting function for a numerics/statistics library based on the assumption that, after filtering out any NaNs and doing a little bit twiddling, floats can be compared as 32-bit ints without changing the result and doubles can be compared as 64-bit ints. This seems to speed up sorting these arrays by somewhere on the ord...

How to convert Java long's as Strings while keeping natural order

I'm currently looking at a simple programming problem that might be fun to optimize - at least for anybody who believes that programming is art :) So here is it: How to best represent long's as Strings while keeping their natural order? Additionally, the String representation should match ^[A-Za-z0-9]+$. (I'm not too strict here, but a...

Use Sort Whilst Still Retaining Keys

When I use the sort function in php it deletes all of the keys. What's an alternative method? ...

After using an NSArray *sort* method, am I responsible for releasing the returned array.

Hi, Im used to c programming where im responsible for freeing everything, and this objective c funky stuff is throwing some spanners in the work. I am using the below code. NSArray *b = [a allObjects]; NSArray *c = [b sortedArrayUsingDescriptors:sortDescriptors]; Who's responsible for releasing "b" and "c". For the record, "a" is a NS...

how to efficiently get the k bigger elements of a list in python

Hi! What´s the most efficient, elegant and pythonic way of solving this problem? Given a list (or set or whatever) of n elements, we want to get the k biggest ones. ( You can assume k<n/2 without loss of generality, I guess) For example, if the list were: l = [9,1,6,4,2,8,3,7,5] n = 9, and let's say k = 3. What's the most efficient a...

Fetch posts starting with alphabet [x]

<?php $temp_query = $wp_query; ?> <?php query_posts('tag=sometag,anothertag&posts_per_page=10'); ?> <?php while (have_posts()) : the_post(); ?> // print post here <?php endwhile; ?> <?php $wp_query = $temp_query; ?> Using this simple wordpress loop, how do I show ONLY the posts (post titles actually) starting with say letter 'G'. I...

MySQL sort by average of two averages

I am working on a contest site where there are two types of users, normal site members, and judges. Each can use a drag and drop tool to order the entries in a particular contest in the order they choose. When they are done the relevant entry ids are attached a ranking value that can then be used to determine which entry in contest got t...

array of array sort_by with nil elements (ruby)

I have code that sorts the way I want. By multiple fields. Cool. But now I realized that sometimes the elements could be nil. Q1: Any idea how to manage to get nil values at the top of the search? And get rid of this error message :in "<=>": undefined method "<=>" for nil:NilClass (NoMethodError) Q2: in the code below I sort by 3 elem...

Optimize Pagination & Sorting with ObjectDataSource having EnableCaching = true

I'm using an ODS(ObjectDataSource) backed-up with a Linq-To-SQL class to populate Gridview on my page. Considering the performance - I've disabled the Viewstate of the Gridview and enabled caching in the ODS. Apart from this, I've also optimized the Search method in the Linq-to-SQL class to use the .skip & .take methods to fetch only a...

as3 sorting xml data ?

I have xml data that I can load into my flex app; however, I need to sort it by node. I'm trying to create a combobox or listbox that can display a list of locations sorting them either alphabetically or by the category they are in... I can't get my head around how to format the xml or how to code the flash file to sort according to lo...

Sorting dictionary keys by values in a list?

I have a dictionary and a list. The values of the keys match those of the list, I'm just trying to find out how to sort the values in the dictionary by the values in the list. >>> l = [1, 2, 37, 32, 4, 3] >>> d = { 32: 'Megumi', 1: 'Ai', 2: 'Risa', 3: 'Eri', 4: 'Sayumi', 37: 'Mai' } I've tried using somethin...