sorting

Sorting my ArrayAdapter doesn't change my data source

I am having a weird issue. I have an ArrayAdapter which I am sorting. This displays properly on my screen, however when I check the actual data source, the contents have not been sorted. How can I ensure that sorting my ListAdapter will also sort my data source? Collections.sort(quotes, new PercentChangeComparator()); //sort my data sou...

Sorting ArrayList Not Working Properly

I am trying to sort my ArrayList, but when I check the first item in my supposedly sorted array, it is incorrect. I am not sure why? Am I missing anything? Here is my Comparator: package org.stocktwits.helper; import java.util.Comparator; import org.stocktwits.model.Quote; public class NameComparator implements Comparator<Quote> { ...

Reporting services + sort expression

Greetings, In my reporting services I would like to add sorting. Is there any way I can add sorting by two fields inside one column's sort expression? something like: =Fields!SomeValue1.Value =Fields!Somevalue2.Value when I use this sort expression, values are not sorted correctly. Values I would like to sort are something like Som...

How do I sort the elements of argv in C?

I am trying to alphabetically sort the elements of argv. The following line of code is giving me problems: qsort(argv[optind], argc - optind, sizeof(argv[optind]), sort); Specifically, the last argument is giving me trouble, the comparison function, which is given below: int sort(const void *a, const void * b) { return(st...

RichFaces ExtendedTableDataModel: sorting columns retrieves all rows

We use the ExtendedTableDataModel for paging. This is done to retrieve a set of results with Hibernate and load the next set when another page is requested. All works fine, but if we sort columns by using rich:column sortBy within the rich:dataTable then RichFaces tries to load all rows. We can see this while debugging the getItemsByRa...

How to sort a "Book" ArrayList without SQL?

My Book app gathers a collection of Book objects using lookups against different Merchant objects: List<Book> books = new ArrayList<Book>(); for (Merchant merchant : merchants) { books.addAll(getBooksForMerchant(merchantName); } It has to sort the List on the basis of a dropdown box: <select class="sortByDropdown" name="sort"> <o...

How to make tds stack after sort using jQuery

You can see the full problem here: http://users.cjb.net/syn4k/test.htm I have described the problem in full at this location. Edit: since you have asked to see the problem here as well, Drag and drop the outlined items from one column to another and then try sorting the items in that column Issue: The items do not stack after sort but r...

Java extended collection filtering

I have to filter and to sort a ArrayList wíth objects. - Every object has 2 integer pairs => 4 ints per Object. - Every value of Column_1 < Column_2 and - Every value of Column_3 < Column_4. ... so each pair represents a distance. 1.) Distance in 1st(Column_1,Column_2) pair and 2nd(Column_3, Column_4,) pair have to be equal. 2.) if t...

Sorting a collection of numeric Strings

Hi, I need the ability to sort a collection of customers which contains a property of numeric string. How Can I sort the below collection by code in numeric order. Again Code is a string. class Program { static void Main(string[] args) { SortableObservableCollection<Cus...

Multi Array Sort PHP

I'm having some problems wrapping my head around how to do this. I have an array in PHP array(131) { ["BLANF "]=> array(3) { ["line_3"]=> string(4) "3.92" ["line_1"]=> string(1) "6" ["line_2"]=> string(2) "14" } ["BLOOH "]=> array(3) { ["lin...

Fastest safe sorting algorithm implementation

Hi everybody! I spend some time implementing a quicksort algorithm in C#. After finishing I compared the speed of my implementation and C#'s Array.Sort-Method. I just compare speed working on random int arrays. Here's my implementation: static void QuickSort(int[] data, int left, int right) { int i = left - 1, j = right; ...

java comparator for simple custom logic

How I can find line 4,1 and 6 in example below? And is the use of Collection.sort() with Comparator reasonable in this case? a - b - c - d 1.) 6 8 16 18 2.) 38 40 55 57 3.) 6 8 25 27 4.) 1 5 11 15 5.) 6 8 3 5 6.) 9 12 19 22 7.) 18 20 1 3 8.) 23 25...

Sort a ArrayList<String> by number value

I have an ArrayList of video resolutions that looks like this: "1024x768", "800x600", "1280x1024", etc I want to sort it based on numeric value in first part of string. Ie, the above would sort out to look like this: "800x600","1024x768","1280x1024" Is there a quick and dirty way to do this, by that I mean in less then 2-3 lines of c...

Sorting Erlang records in a list?

Hi, I have a record in erlang: -record(myrec, { id = 0, price = 0, quantity = 0 }). I then have a list of records that I want to sort by id and price, both in descending and ascending order, where price is the first key and if two records have the same price I want to sort those by id. How can I define a f...

Jquery DataTables change order to desc when it sorts

I am using DataTables to display some data and it works great but I want to customize it slightly and not sure how. What I want to do is when a user clicks on a column heading to sort that column I want it to initially order descendingly rather than ascendingly. Is there any way to do this? ...

Jquery TableSorter not sorting numbers

Hi, I am using Jquery table to sort my table but its not doing it for numbers. My data is like that 12,235.25 8,238.45 10,235.25 9,230.23 7,230.17 6,230.17 Please help how can I change my code? ...

optimize dom-heavy JS sorting

Hi guys, So I've built this mail-program-like HTML viewer (no real emails, just some messages from user to user). It basically behaves just like windows explorer, where you have the labels at the top and the files you can sort by date or alphabetically. Each message looks like this: <div class="mail_msg" d_id="363"> <div class="don...

Sorting while preserving order in python

What is the best way to sort a list of floats by their value, whiles still keeping record of the initial order. I.e. sorting a: a=[2.3, 1.23, 3.4, 0.4] returns something like a_sorted = [0.4, 1.23, 2.3, 3.4] a_order = [4, 2, 1, 3] If you catch my drift. ...

Sorting an Array

Hello, I have an array containing all string values. Contents of the array are order_id, waypoint_x, waypoint_y. How do I sort it based on order_id and have the results like 1, 2, 3, 4.... (i.e. as if the field was an integer type and string) When I use the waypoints as the array is at the moment the results come out 1, 10, 11, 12... ...

How to sort an NSArray of objects by their class?

I have an NSArray of objects that all subclass with their different types from a more abstract class. I would like to sort the array by the object's class type. For example: NSArray with CLASSA CLASSB AND CLASS C subclassed from CLASSz myArray = {C, B, A} Sort myArray decending: {A, B, C} I see sort descriptors and that seems like i...