sorting

Need help understanding how the List<T>.Sort(IComparer(T)) knows the value to sort on

I am working on a program (learning C#) that creates a object (Card) and in the program it sorts the deck of cards by value. What I am baffled by is how it is able to sort a deck of cards by the value of the cards when the instance of the object isn't the parameter passed to the method but the class object. Below is the code to help an...

how to sort file in ruby.

This is my file content. Receivables=Por cobrar Payables=Cuentos por pagar ytdPurchases.label=Purchases YTD validationError.maxValue=Value is too large, maximum value allowed is {0} i want to sort this content in alphabetic order ... how may i do that ?? Update: This code will sort my file. new_array = File.readlines("#{$base_prope...

How to add arrow to each WPF listview column to indicate sort direction

Hi, I have a gridview ...with multiple columns. If I click on one column, it sorts the gridview based on that column values. I like to add an arrow in that "clicked" column header(when user clicks) to show that "this particular column is clicked and this is the sort direction" How can I do this? I saw a sample link http://stackoverflo...

NHibernate sorting (SQL as a second option)

I'm using NHibernate as my ORM and I'm trying to sort some data. The data needs to be retrieved paged. Two of the columns in my Request table are UrgencyID and CreateDate. UrgencyID is a FK to the Urgency table with static data: 1 = Low, 2 = Normal, 3 = High, 4 = Critical. I need to order my Requests in the following manner. Critica...

How to search in a Set (using a Comparator)

Hi, I want to search in a Set without iterating manually over the elments but there does not seem to be a method to do Collections.search(myset, target, new ComparatorThing()). Am I not seeing something? Thanks. Edit: I am searching for another field than the natural order of the elements. As a manual workaround I used the following...

Query for lucene search result

I have a storage of news with the following fields (Title, Body, NewsDate) I need a best query with the following criteria 1) title is more important but less than date 2) date should be compare to the current date if the date of a document is near the current date it is more valuable (NOTE: It doesn't mean that sorting descending on n...

Forward Back Records in MySQL with the same DATA in the primary

I have a table that is is sorted 1st by Reminder Date then ID Table Looks like: ID | remind_date 1 2011-01-23 2 2010-02-21 4 2011-04-04 5 2011-04-04 6 2009-05-04 I am using a PHP front end to move forward and back thur the records. I want to have forward and back buttons but i am running into a problem with the 2...

How would you sort an array in Ruby based off of a formula (e.g. search ranking)?

So, I'm building quick and dirty search functionality in my first rails app. I'm doing a query and returning a list of objects. e.g. @articles = Article.find_by_sql("select * from article where title like "%test%" or title like "%foobar%") So, the articles collection will return a lot of data, some of it matching my search terms bet...

Sorting/Displaying a large data set within a browser - how much JSON is too much?

Hello all, This is a technical question regarding browser limitations for parsing and sorting JSON. We are looking at performing a clustering algorithm on large data sets (potentially 50k rows, potentially 10 fields per row) that are returned from a query and displayed to users in a table, 25 rows per page, and sortable on all fields...

Ascending/descending ordering of Django QuerySet when one attribute is a model method

I have a QuerySet of teams ordered by school name. One of the attributes is a model method that keeps track of the team's winning percentage. I want to order the teams from highest winning percentage to lowest. If teams have the same winning percentage, I want them to be ordered alphabetically by school. How do I get something like this:...

Trying to sort a custom JavaScript object

Hi, I'm not too good at JS, but have survived thus far. I'm creating a sort-of complex JS object and wanting to sort it. The object's structure looks like this: cart.attributes = [ { Attribute, Value } ... ]; I'm creating a unique attribute that tells me 3 things separated arbitrarily by a colon: (Product ID):(Product...

Using XSL to sort XML data then output an XML file to be read by Classic ASP

Hi, Hopefully this will be a simple fix. I'm completely new to XSL but I've managed to get a little script that sorts my data by date. I now want to use ASP to limit this data to all entries within a month (this works by using a DateDiff() function). When I go to load in the XSL scripts output it says that my XML is malformed. Can anyon...

Excel VBA alternative way of sorting by date

Hi, I'm currently working on a document which has about 25 columns, each headed by a date. Now I have to sort these columns by date. However, the sorting should not start with January and run until December. In my document, the sorting should start with September, and run until June (July and August can be omitted, as my document relate...

Android: Sorting a merged cursor

Hi, I'm wondering if there's any way to merge two cursors together and then resort them. I can easily merge two cursors together by using a MergedCursor, but that doesn't sort them. I have two sets of contacts in two separate cursors (with totally different schemas) and I want to merge them and sort them by name (the name column is di...

sort NSArray of UIImagerview?

Hi all, i want to sort NSArray of UIImageView according their frame? i try for NSSortDescriptor but when i write key=@"frame" unrecognized selector error occur. please tell me how to sort my array. thanks in advance. ...

Custom Sorting in .NET

I have designed a Class for Parent Child relationship class Category { public string CatName; public string CatId; public IList<Category> childCategory = new List<Category>(); public void addChildCat(Category childCat) { this.childCategory.Add(childCat); } public Category SortedCategory(Category ...

Sorting array of dates stored in a string

Is there away i can sort the following array into the correct order? Array ( [0] => apr [1] => aug [2] => dec [3] => feb [4] => jan [5] => jul [6] => jun [7] => mar [8] => may [9] => nov [10] => oct [11] => sep ) NOTE The array comes to me like this, and sometimes it will not have all th...

Is stdlib's qsort recursive?

I've read that qsort is just a generic sort, with no promises about implementation. I don't know about how libraries vary from platform to plaform, but assuming the Mac OS X and Linux implementations are broadly similar, are the qsort implementations recursive and/or require a lot of stack? I have a large array (hundreds of thousands of...

Problem sorting an array of objects by date & time in Javascript - null values allowed

I'm working with an array of objects in Javascript and need to sort them by date and time. Here's the setup: place title date (optional) time (optional) Conceptually, the application allows users to create a list of places they're planning to go. The array of events is manually ordered at first, and users can optionally add date ...

Java & Merge Sort

Why Java impl choose merge sort over quick sort? and why do they copy the content to an array? API: "The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n log(n) performance. This impl...