ordering

Advice on creating admin panel where user can upload, remove and order the files

I'm working on a website where a logged-in admin needs the ability to upload and manage multiple PDFs from their computer. They'd need to be able to upload/remove the files. Also, there would need to be a way that they can sort the list of uploaded files and save that order so that other visitors to the page would see the list of files i...

How to do case-insensitive order in Rails with postgresql

I am in the process of switching my development environment from sqlite3 to postgresql 8.4 and have one last hurdle. In my original I had the following line in a helper method; result = Users.find(:all, :order => "name collate NOCASE") which provided a very nice case-insensitive search. I can't replicate this for postgresql. Should b...

Efficient way to store order in mySQL for list of items

I want to code cleaner and more efficiently and I wanted to know any other suggestions for the following problem: I have a mySQL database that holds data about a set of photograph names. Oh, say 100 photograph names Table 1: (photos) has the following fields: photo_id, photo_name Ex data: 1 | sunshine.jpg 2 | cloudy.jpg 3 | rainy.jpg...

Defining your own Ord for a data type (Haskell)

I am attempting to make some data structures to solve a graph puzzle. I am trying to define an edge's comparison criteria, but I am not sure how. So far: data Edge = Edge (Set String) Bool How do I tell let the compiler know that I want edges to be declared equal if they have identical sets of strings, and not have equality have anyth...

Does the foreach loop in C# guarantee an order of evaluation?

Logically, one would think that the foreach loop in C# would evaluate in the same order as an incrementing for loop. Experimentally, it does. However, there appears to be no such confirmation on the MSDN site. Is it simply such an apparent answer that they did not think to include that information on the site? Or is there the possibili...

Cakephp, ordering associated tables.

Hi, When I search a model which "has many" of something else. For example a blog post has many categories. When searching for blog post with categories associated, how do I order the associated categories? When the array is returned it ignores the order on the category model and defaults to it's usual id order. Cheers. ...

Search Logic removing records with no association from results when ordering by that association

I'm using search logic to filter and order my results but it removes records from my results when I order by a association and when that association is not always present for all records. For example say I have a user model which can have one vehicle model but does not have to, if I have a results table where you can order by the users ...

Ordering in dropdown in MVC

Hi I've a problem with a dropdown in a view in MVC. The option-elements in the dropdown comes from a table and should be ordered by a hierarchyId column. I've made a view which orders correctly, but when I create my entity from the view and use it for the dropdown the ordering is ignored. I found out that hierarchyId datatype is not s...

How does order matter in .NET delegate concatenation?

Here's the situation. I'm reviewing some SDK code that I didn't write because I've been tasked with drafting the developer's documentation. In one class, in the constructor, event handling is set up like this: _engine.ReceiverEvents_OnPosition += OnPosition; _engine.ConnectionEvents_OnDeviceStatus += OnDeviceStatus; _engine.ConnectionEv...

SQL 2008 Spatial ordering of objects

I have a dataset containing the start and end points (both OSGB36 and corresponding WGS84 coordinates) of sections of a road network. I am able to import this data in SQL and create geometry and geography data types for the start and end points and for the entire object (LINESTRING etc). Viewing the coordinates in SQL query window enab...

MySQL: Ordering within grouping?

So I have this messages database between members in my CMS. I wanted to change the listing to show people instead of specific messages. Call it "threads" but each thread in the "my messages" page is a member that you've had a conversation with, right? So, I obviously do this with something like this: select id, msgfrom, headline from m...

Custom Sort Order - How to not duplicate the Case statement

I have the following Db and query. The query takes two parameters: the sort column and the direction. However, I have to add custom sorting to the query (based on the Fuji should come first and Gala second, etc.). This part also work but it create duplicated code in my query. Because of that, I am pretty sure people will not let me check...

Prevent ListView from reordering items

I have a ListView that is backed by a CursorAdapter. The cursor passed into the adapter is a MergeCursor. It is a MergeCursor because I have two tables, type1 and type2. I want to list all of the elements from type1 and type2 in a single ListView with all of the elements from type1 first, and all of the elements from type2 last. In a...

PHP and wordpress: Sorting Menu items

I'm working on a wordpress site, customizing the menu. I'm no php whiz, and I want the menu to sort according to the numerical order, not desc alphabetically. <div id="navigation"> <ul> <?php wp_list_pages('sort_column=post_title&sort_order=desc&title_li=&depth=1&')?> </ul> </div><!-- end id:navigation --> Any ideas how I do ...

default_scope :order => :index does not works

I have a simple models class Item < ActiveRecord::Base has_many :parts end class Part < ActiveRecord::Base belongs_to :item default_scope :order => :index end Each part has it's own index, to be ordered inside of the Item in question. When i load parts for the item in ItemsController.show method, the parts are not ordered. ...

XPath: how to sort a nodeset obtained by an expression using an expression?

I have a group with the following attributes: <mygroup> <item id="0"> <item id="1"> <item id="2"> </mygroup> when I cal the expression /mygroup/item I need to re-order the nodeset according the attribute "id", there is a way to do it without using the sort template? ...

Maintaining order of items in java

What is the best way to do the following(make sure that items from List are following the same order as those in ListTwo): List harry~20 marry~22 peter~40 jerry~33 janice~20 ListTwo harry marry peter janice Now the result should look like this ListThree harry marry peter janice jerry Step by step : For each item in List : ...

Order a container by member with STL

Suppose I have some data stored in a container of unique_ptrs: struct MyData { int id; // a unique id for this particular instance data some_data; // arbitrary additional data }; // ... std::vector<std::unique_ptr<MyData>> my_data_vec; The ordering of my_data_vec is important. Suppose now I have another vector of IDs of My...

NHibernate ICriteria - order by child collection count ?

Hi, Here is a simple example scenario - A 'Tag' has many 'Questions'. When I get a list of Tags how do I order by the Tags Question Count using the Criteria API? I have done this before but haven't touched NH in about 4 months and have forgotten... projections maybe? help!!! Thanks ...

ordering a hashset example?

need an example on how to use a comparable class on a hashset to get an ascending order? Let say we have a hashset like: HashSet hs=new HashSet(); How can i get the hs to be in a ascending order?? ...