sorting

How to sort in SQL, ignoring articles ('the", "a', "an" etc)

This comes up a lot, and I can see it's come up on StackOverflow for XSLT, Ruby and Drupal but I don't see it specifically for SQL. So the question is, how do you sort titles correctly when they begin with "The", "A", or "An"? One way is simply to TRIM() those strings: ORDER BY TRIM( LEADING 'a ' FROM TRIM( LEADING 'an ' FR...

Flex AdvancedDataGrid sort

I have an AdvancedDataGrid that is being populated by customer data. Each customer has 3 monthly products(1, 3, 6), and also a passed field specifying whether the customer qualifies for any of the monthly products. Now the grid is sorting the customer data alphabetically, which is a good thing, but it isnt sorting the monthly products,...

Is there algorithm for sorting array of strings for GPU?

Array to sort has approximately one million strings, where every string can have length up to one million characters. I am looking for any implementation of sorting algorithm for GPU. I have a block of data with size approximately 1MB and I need to construct suffix array. Now you can see how it is possible to have one million strings i...

Is partitioning easier than sorting?

This is a question that's been lingering in my mind for some time ... Suppose I have a list of items and an equivalence relation on them, and comparing two items takes constant time. I want to return a partition of the items, e.g. a list of linked lists, each containing all equivalent items. One way of doing this is to extend the equiv...

sorting a list of tuples

I have a list of tuples of the form (a,b,c,d) and I want to copy only those tuples with unique values of 'a' to a new list. I'm very new to python. Current idea that isn't working: for (x) in list: a,b,c,d=(x) if list.count(a)==1: newlist.append(x) ...

String Selection Sort C++

How would I modify a selectionSort function to search an array of strings? void selectionSort (int array[], int size) { int startScan, min Index, minValue; for (startScan = 0; startScan<(size-1); startScan++) { minIndex=startScan; minValue=array[startScan]; for(int index = startScan + 1;index<size;ind...

Sort list by given order of indices -Python

I have a list of lines read from a file. I need to sort the list by time stamp (in UTC), however the time stamp is not always at the beginning of the string. I have parsed out the time stamp using regular expressions and place them into a separate list. The indices of the two lists will match. Once I sort the list of time stamps, I can g...

Puzzle: Need an example of a "complicated" equivalence relation / partitioning that disallows sorting and/or hashing

From the question "Is partitioning easier than sorting?": Suppose I have a list of items and an equivalence relation on them, and comparing two items takes constant time. I want to return a partition of the items, e.g. a list of linked lists, each containing all equivalent items. One way of doing this is to extend th...

Highlight column of grid

i need to highlight a column of a grid when clicked for sorting. ...

Flex AdvancedDataGrid - Remove sort arrow

Is it possible to completely remove the sort arrows on an AdvancedDataGrid header? I know that you can kinda do this by using <mx:AdvancedDataGrid sortExpertMode="true"/> and I even tried using <mx:AdvancedDataGrid sortExpertMode="true"> <mx:columns> <mx:AdvancedDataGridColumn sortable="false" /> This doesnt work be...

How can I sort rows across two ListView controls in VB6?

I have two ListViews side by side in a VB6 project both holding data from the same source. I have each ListView sorting it's own values when the column headers are clicked, but how can I make it sort the data from both ListViews and move rows between the two listviews as needed? ...

Sort mySQL table's fields

So lets say I have a table (lets say 50 rows, 50 columns) that I occasionally have to make tiny edits to. While I realize I could be (maybe some of you will tell me I should be) using the query to do this, I like using a database management program (like Sequel Pro) to make changes by hand. So I have two questions: When you do a query ...

loop until all elements have been accessed N times in python

I have a group of buckets, each with a certain number of items in them. I want to make combinations with one item from each bucket. The loop should keep making different combinations until each item has participated in at least some defined number. I can easily see how to run the loop and stop once a single element has been accessed a c...

Red Black Tree for Sorting

The worst-case running time of insertion on a red-black tree is O(lg n) and if I perform a in-order walk on the tree, I essentially visit each node, so the total worst-case runtime to print the sorted collection would be O(n lg n) I am curious, why are red-black trees not preferred for sorting over quick sort (whose average-case running...

Correctly sorting doubles with JTable

I have a table where the first column contains Strings and the second contains doubles. stars = new StarDatabase(path); Object[][] data = new Object[stars.size()][2]; int i = 0; for (String name : stars.keySet()) { data[i][0] = name; data[i++][1] = stars.get(name).period; } StarsTable = new JTable...

inconsistent sort behavior

I have a sample file containg "aA0_- " characters on each one on a single. Sorting it using GNU sort gives the following sort order: $ cat /tmp/sample | sort _ - 0 a A after appending some other character, we obtain a different order (non-alphanumeric characters seems to have lower priority): $ cat /tmp/sample | sed 's/$/x/' | sort ...

what's bubble sort good at?

Possible Duplicate: What is a bubble sort good for? I'am sure every algorithm has its advantage and disadvantage, so how about buble sort compared to other sorting algorithm? (ofcourse I hope the answer is other than "easy to learn") ...

How to sort images into rows in C

Very simple problem, but can't seem to solve it. I'm probably just not thinking right. So I'm using C and I need to be able to sort some images I download into two rows. Like this: http://i.imgur.com/lWkEO.png So my program will, say, download 30 images and it has to sort it into these two rows just like you see in the picture. So I know...

In Javascript: Load some collection of data, randomly sort it, return it for output

I am loading some XML data, building it into an unordered list and displaying it. I now need to sort this data so it is displayed in a random order each time it is loaded. Do I need to completely change how I am doing this below or is there an easy way to get the data and sort it before using my existing code to format it for output? He...

sort an associative array

How do i sort this array by ssup asc? [xml] => Array ( [sale] => Array ( [0] => Array ( [ref] => 316205 [line] => 3 [partno] => MC41SS [cust] =...