sorting

Order Django admin change list column by output of __unicode()__ method

Here's part of my Django app's models.py: class Person(models.Model): birth_year = WideYear(null=True, blank=True) birth_year_uncertain = models.BooleanField() death_year = WideYear(null=True, blank=True) death_year_uncertain = models.BooleanField() flourit_year = WideYear(null=True, blank=True) flourit_year_unce...

How to select first 'N' records from a database containing million records?

I have an oracle database populated with million records. I am trying to write a SQL query that returns the first 'N" sorted records ( say 100 records) from the database based on certain condition. SELECT * FROM myTable Where SIZE > 2000 ORDER BY NAME DESC Then programmatically select first N records. The problem with this approac...

Sorted List has oposite order after each reload. I want only Desc.

I have List I want to sort Desc by Priority, which is int and can be anything from 0 to 100. I use GenericComparer, which allows to set the SortDirection and sortExpression. Works well for any string property, like a Name (which is property of ProductLowDetail). However for Priority it behaves strange. It does sort, but it changes the di...

What is a better way to sort by a 5 star rating?

I'm trying to sort a bunch of products by customer ratings using a 5 star system. The site I'm setting this up for does not have a lot of ratings and continue to add new products so it will usually have a few products with a low number of ratings. I tried using average star rating but that algorithm fails when there is a small number of...

Find largest and second largest element in a range

How do I find the above without removing the largest element and searching again? Is there a more efficient way to do this? It does not matter if the these elements are duplicates. ...

Sorting by a field of another table referenced by a foreign key in SQLObject

Is it possible to sort results returned by SQLObject by a value of another table? I have two tables: class Foo(SQLObject): bar = ForeignKey('Bar') class Bar(SQLObject): name = StringCol() foos = MultipleJoin('Foo') I'd like to get foos sorted by the name of a bar they are related to. Doing: foos...

What is the fastest possible way to sort an array of 7 integers?

This is a part of a program that analyzes the odds of poker, specifically Texas Hold'em. I have a program I'm happy with, but it needs some small optimizations to be perfect. I use this type (among others, of course): type T7Cards = array[0..6] of integer; There are two things about this array that may be important when decidin...

Loading jqgrid from qury with multiple joins

I am trying to load a sortable jqgrid 3.5 from a query with multiple joins in it and having much difficulty as I am a novice with both Linq and jqgrid. In order to allow for sorting I first was attempting to load it using dynamic sql. Since I am pulling columns from multiple tables I assume my return will be a class object which I will p...

How to sort dataset.table[0] then get the top 10 ?

I'm adding an auto increment column (called "rowNum") to my table and it's working good, after that I use this code to sort datatable rows : DataView dv = MyDataSet.Tables[0].DefaultView; dv.Sort = "columnName DESC"; where columnName is one of my columns (not the auto increment one). Now,The problem is: when I want to get the top 10 ...

How to save reordered rows only on pressing the Done button?

Hey all, if i reorder rows on my table view, is it possible to save the result only if the user pressed the "Done" Button? (Reorder is working great, but i only want to commit the final result of the positions if the user pressed the Done Button, and not every time a row is moved.) Is there something like editingStyle == UITableViewCel...

How do I sort a list with multiple sort parameters?

I have a class named Person with multiple properties, for example: public class Person { private int id; private String name, address; // Many more properties. } A lot of Person-objects are stored in an ArrayList<Person>. I want to sort this list by multiple sort parameters, and different from time to time. For instance I ...

jquery drag and drop

i am using jquery for drag and drop its works fine with 2 divs, i can drag image across 2 divs one div is drag able other is drop able what i want is to have 4 divs, where i have images in each div and i can drag imge from one div to other. is this possible in jquery ? if yes can you write a little code for me...? Thanks ...

How to sort javascript object array by element.name

Hi, I am try to write some validation script using javascript and prototype. What I want to do is to loop through all the elements of a form and validate each answer. My code works, BUT the array of DOM elements is unsorted. I would like to sort the elements by their ID. Here is the my code, which works fine if I comment-out elem.s...

c# string sorting VS Oracle string sorting

Hi! I have to sort a list of strings in exactly the same way as they are returned to me from an oracle database. Unfortunately Oracle returns them in such a way, that numeric characters are sorted after alphabetic. For example: Alabama x-men 100 new ideas 9 months ... How could I sort a list of strings in C# in such a way? ...

Fast stable sorting algorithm implementation in javascript

I'm looking to sort an array of about 200-300 objects, sorting on a specific key and a given order (asc/desc). The order of results must be consistent and stable. What would be the best algorithm to use, and could you provide an example of it's implementation in javascript? Thanks! ...

Hierarchical (Multi-column) Sorting for the .net GridView?

Is there a simple ".Net" way to do hierarchical sorting Table... A|B|C ----- 1|2|5 2|8|4 2|4|3 3|7|2 4|4|1 clicking on A, then B would get you.. A|B|C ----- 1|2|5 2|4|3 2|8|4 3|7|2 4|4|1 The change being that I'm sorting (B) in context of (A) and so forth. Obviously this could be managed in the datasource, but was wondering if s...

Using XSL to sort attributes

I'm trying to canonicalize the representation of some XML data by sorting each element's attributes by name (not value). The idea is to keep textual differences minimal when attributes are added or removed and to prevent different editors from introducing equivalent variants. These XML files are under source control and developers are wa...

ASP.NET MVC - Model.OrderBy Date has no effect

Hello, I'm having some difficulties to sort my results by Date. Is there any special method? Because I'm doing this right now: var db = new DB(); var articles = db.Articles; var orderedArticles = articles.OrderBy(a => a.Date); return View(orderedArticles.ToList()); Where Date is a datetime field. And there is no effect for OrderBy(..)...

How do i sort objects?

Hello everyone, I've created a class and created an array of objects under that class and filled it all up with data. Now i want to sort the entire array by a specific member of that class, how do I do this using the stable_sort() function? Edit: Ok, i have this right now, class sortContiner { public: double position; int ke...

Python sort() method on list vs builtin sorted() function

I know that __builtin__ sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured. """ Example Output: $ python list_sort_timeit.py Using sort method: 20.0662879944 Us...