Search Results

Search found 3659 results on 147 pages for 'sorted hash'.

Page 93/147 | < Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >

  • Linq to SQL ordered child collection

    - by Matt Connolly
    Is there a way to define a default order column from a child collection? In my case, I have a Form entity that has a collection of FormItem entities called FormItems. FormItem has a property called DisplayOrder (int). I want to make sure that any Form entities I return from a method have that collection properly ordered. Is there a way to do this before returning the result? For example, I tried this but the list is not actually sorted: var form = context.Forms.FirstOrDefault(x => x.IsDeleted == false && x.FormName == formName); if (form != null) { form.FormItems.OrderBy(x => x.DisplayOrder); // I can't even figure out a way to cast this next line so that it will compile // form.FormItems = form.FormItems.OrderBy(x => x.DisplayOrder); } return form; Is there a way to do this without using DataLoadOptions?

    Read the article

  • Sqlite: Selecting records spread over total records

    - by Martin
    I have a sql / sqlite question. I need to write a query that select some values from a sqlite database table. I always want the maximal returned records to be 20. If the total selected records are more than 20 I need to select 20 records that are spread over the total records. It is also important that I always select the first and last value from the table when sorted on the date. I know how to accomplish this in code but it would be perfect to have a sqlite query that can do the same. The query Im using now is really simple and looks like this: "SELECT value,date,valueid FROM tblvalue WHERE tblvalue.deleted=0 ORDER BY DATE(date)" Hope I explained what I need, thanks for your help!

    Read the article

  • Determine file creation date in Java

    - by Todd
    Hello, There is another similar question to mine on StackOverflow (How to get creation date of a file in Java), but the answer isn't really there as the OP had a different need that could be solved via other mechanisms. I am trying to create a list of the files in a directory that can be sorted by age, hence the need for the file creation date. I haven't located any good way to do this after much trawling of the web. Is there a mechanism for getting file creation dates? Thanks, Todd BTW, currently on a Windows system, may need this to work on a Linux system as well. Also, I can't guarantee that a file naming convention would be followed where the creation date/time is embedded in the name.

    Read the article

  • JTable filled with database data is not being updated when columns are reordered.

    - by marionmaiden
    I have a JTable filled with data of a table of my database (so I used ResultSetTableModel) and using TableRowSorter to sort the rows, as I click in one column of the JTable. The data is displayed in the jTable without problems; But when I sort the JTable by some column table (for example, sorting it by the primary key value), and edit some cell from the sorted jTable, the value changed is the old cell that were in that position before the ordenation of the column. For example: Suppose I have a table with 2 columns - name and age. My table has the following data: c 1 b 2 a 3 when I order i by name in the JTable, it becomes like this a 3 b 2 c 1 if I edit the value "1", after the edition, the table becomes like this a 1 b 2 c 1 It seems that the positions are not being updated in the JTable, and the values are edited considering their original positions.

    Read the article

  • Sharepoint Blog Posts : Sort based on Published date

    - by Hojo
    I have a sharepoint intranet portal which has many blogs and they have customized design. We use default Data form webpart for displaying blog posts. By default the posts are sorted based on "created date". I have a new requirement from the client asking me to change the sorting criteria to "Published date". What is the easiest method to achieve this without using SharePoint Designer . Note: Creating a new view is not a solution as I will not be able to apply the customized design.

    Read the article

  • Gravity Sort : Is this possible programatically?

    - by Bragaadeesh
    Hi, I've been thinking recently on using the Object Oriented design in the sorting algorithm. However I was not able to find a proper way to even come closer in making this sorting algorithm that does the sorting in O(n) time. Ok, here is what I've been thinking for a week. I have a set of input data. I will assign a mass to each of the input data (assume input data a type of Mass). I will be placing all my input data in the space all at same distance from earth. And I will make them free fall. According to gravitational law, the heaviest one hits the ground first. And the order in which they hit will give me the sorted data. This is funny in some way, but underneath I feel that this should be possible using the OO that I have learnt till date Is it really possible to make a sorting technique that uses gravitational pull like scenario or am I stupid/crazy?

    Read the article

  • Polymorphic association in reverse

    - by Erik
    Let's say that I have two models - one called Post and one other called Video. I then have a third model - Comment - that is polymorphically associated to to each of these models. I can then easily do post.comments and video.comments to find comments assosciated to records of these models. All easy so far. But what if I want to go the other way and I want to find ALL posts and videos that have been commented on and display these in a list sorted on the date that the comment was made? Is this possible? If it helps I'm working on Rails 3 beta.

    Read the article

  • a loading screen for a c# wpf listbox

    - by evan
    I'm using a list box where there are on average about 500 thumbnails (items) that can be sorted and searched. Since I'm using default databinding and search descriptors (which I've heard are slow due to reflection) the list takes a noticeable pause of a few seconds loading, sorting, and searching (the list dynamically updates based on the contents of the search box so the first one or two letters typed are really slow). I don't think I can fully do away with reflection give the timeframe for the project, and speed isn't super essential, but I'd like some kind of graphical indication of the delay so it doesn't confuse the user. How could I do something like a website video loading screen where the listbox grays out and some kind of loading circle indicates it's processing until the list is ready? Or even just grayed out with the words "Loading..." for a few seconds could work. Any ideas? Thanks in advance for your help and suggestions!!!

    Read the article

  • Setting checkstate on a ListWidgetItem

    - by viraptor
    Hi, I'm trying to create a list of checkbox items that change the status on activation. I can connect the activate signal and everything seems to work, but changes on the screen. Am I missing some steps here? Here's the list creation: self.listField = QtGui.QListWidget(self) muted_categories = qb.settingsCollection['mutedCategories'].split('|') main_categories = sorted(set(qb.categoryTopNames.values())) for category in main_categories: item = QtGui.QListWidgetItem(category, self.listField) item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) if category in muted_categories: item.setCheckState(QtCore.Qt.Checked) else: item.setCheckState(QtCore.Qt.Unchecked) self.listField.connect(self.listField, QtCore.SIGNAL('itemActivated(QListWidgetItem*)'), self.doItemChangeState) and here's the handler: def doItemChangeState(self, item): """ invert the state of the activated item """ if item.checkState() == QtCore.Qt.Checked: item.setCheckState(QtCore.Qt.Unchecked) else: item.setCheckState(QtCore.Qt.Checked) I verified that the handler is fired after clicking - if I put prints there, it will alternate "checked" / "unchecked". What can I do to refresh the checkboxes themselves?

    Read the article

  • How fast can you make linear search?

    - by Mark Probst
    I'm looking to optimize this linear search: static int linear (const int *arr, int n, int key) { int i = 0; while (i < n) { if (arr [i] >= key) break; ++i; } return i; } The array is sorted and the function is supposed to return the index of the first element that is greater or equal to the key. They array is not large (below 200 elements) and will be prepared once for a large number of searches. Array elements after the n-th can if necessary be initialized to something appropriate, if that speeds up the search. No, binary search is not allowed, only linear search.

    Read the article

  • PyML 0.7.2 - How to prevent accuracy from dropping after stroing/loading a classifier?

    - by Michael Aaron Safyan
    This is a followup from "Save PyML.classifiers.multi.OneAgainstRest(SVM()) object?". The solution to that question was close, but not quite right, (the SparseDataSet is broken, so attempting to save/load with that dataset container type will fail, no matter what. Also, PyML is inconsistent in terms of whether labels should be numbers or strings... it turns out that the oneAgainstRest function is actually not good enough, because the labels need to be strings and simultaneously convertible to floats, because there are places where it is assumed to be a string and elsewhere converted to float) and so after a great deal of hacking and such I was finally able to figure out a way to save and load my multi-class classifier without it blowing up with an error.... however, although it is no longer giving me an error message, it is still not quite right as the accuracy of the classifier drops significantly when it is saved and then reloaded (so I'm still missing a piece of the puzzle). I am currently using the following custom mutli-class classifier for training, saving, and loading: class SVM(object): def __init__(self,features_or_filename,labels=None,kernel=None): if isinstance(features_or_filename,str): filename=features_or_filename; if labels!=None: raise ValueError,"Labels must be None if loading from a file."; with open(os.path.join(filename,"uniquelabels.list"),"rb") as uniquelabelsfile: self.uniquelabels=sorted(list(set(pickle.load(uniquelabelsfile)))); self.labeltoindex={}; for idx,label in enumerate(self.uniquelabels): self.labeltoindex[label]=idx; self.classifiers=[]; for classidx, classname in enumerate(self.uniquelabels): self.classifiers.append(PyML.classifiers.svm.loadSVM(os.path.join(filename,str(classname)+".pyml.svm"),datasetClass = PyML.VectorDataSet)); else: features=features_or_filename; if labels==None: raise ValueError,"Labels must not be None when training."; self.uniquelabels=sorted(list(set(labels))); self.labeltoindex={}; for idx,label in enumerate(self.uniquelabels): self.labeltoindex[label]=idx; points = [[float(xij) for xij in xi] for xi in features]; self.classifiers=[PyML.SVM(kernel) for label in self.uniquelabels]; for i in xrange(len(self.uniquelabels)): currentlabel=self.uniquelabels[i]; currentlabels=['+1' if k==currentlabel else '-1' for k in labels]; currentdataset=PyML.VectorDataSet(points,L=currentlabels,positiveClass='+1'); self.classifiers[i].train(currentdataset,saveSpace=False); def accuracy(self,pts,labels): logger=logging.getLogger("ml"); correct=0; total=0; classindexes=[self.labeltoindex[label] for label in labels]; h=self.hypotheses(pts); for idx in xrange(len(pts)): if h[idx]==classindexes[idx]: logger.info("RIGHT: Actual \"%s\" == Predicted \"%s\"" %(self.uniquelabels[ classindexes[idx] ], self.uniquelabels[ h[idx] ])); correct+=1; else: logger.info("WRONG: Actual \"%s\" != Predicted \"%s\"" %(self.uniquelabels[ classindexes[idx] ], self.uniquelabels[ h[idx] ])) total+=1; return float(correct)/float(total); def prediction(self,pt): h=self.hypothesis(pt); if h!=None: return self.uniquelabels[h]; return h; def predictions(self,pts): h=self.hypotheses(self,pts); return [self.uniquelabels[x] if x!=None else None for x in h]; def hypothesis(self,pt): bestvalue=None; bestclass=None; dataset=PyML.VectorDataSet([pt]); for classidx, classifier in enumerate(self.classifiers): val=classifier.decisionFunc(dataset,0); if (bestvalue==None) or (val>bestvalue): bestvalue=val; bestclass=classidx; return bestclass; def hypotheses(self,pts): bestvalues=[None for pt in pts]; bestclasses=[None for pt in pts]; dataset=PyML.VectorDataSet(pts); for classidx, classifier in enumerate(self.classifiers): for ptidx in xrange(len(pts)): val=classifier.decisionFunc(dataset,ptidx); if (bestvalues[ptidx]==None) or (val>bestvalues[ptidx]): bestvalues[ptidx]=val; bestclasses[ptidx]=classidx; return bestclasses; def save(self,filename): if not os.path.exists(filename): os.makedirs(filename); with open(os.path.join(filename,"uniquelabels.list"),"wb") as uniquelabelsfile: pickle.dump(self.uniquelabels,uniquelabelsfile,pickle.HIGHEST_PROTOCOL); for classidx, classname in enumerate(self.uniquelabels): self.classifiers[classidx].save(os.path.join(filename,str(classname)+".pyml.svm")); I am using the latest version of PyML (0.7.2, although PyML.__version__ is 0.7.0). When I construct the classifier with a training dataset, the reported accuracy is ~0.87. When I then save it and reload it, the accuracy is less than 0.001. So, there is something here that I am clearly not persisting correctly, although what that may be is completely non-obvious to me. Would you happen to know what that is?

    Read the article

  • How to send to view $data and $data2 at same time?

    - by artmania
    Hi friends, I use codeigniter and issue about how to send to view $data and $data_cat2 at same time? $data['records'] = $this->gallery_model->get_all(1); $data_cat2['records'] = $this->gallery_model->get_all(2); $this->load->view('gallery/index.php',$data); I tried to put an another load-view for $data_cat2. and it just repeated the all page :/ Thanks regards!!! appreciate helps! sorry for silly question, just sorted it! feel shame to ask that: $data['records'] = $this->gallery_model->get_all(1); $data['records_cat2'] = $this->gallery_model->get_all(2); and using the record_cat2 in view file.

    Read the article

  • Sorting List which has object that contains two string members that contains numbers

    - by Lemo
    I want to know the best solution for this my case here is that i am taking values from Excel sheet and pushing them to database field, sometimes that field might contain some strings (thats why I cant make my object members int / double) In my class below size is the variable responsible for showing size of files in bytes public class dataNameValue { public string Name { get; set; } public string Count { get; set; } public string Size { get; set; } } I wanted to sort the list by file Size something like List mylist = new List(); mylist = mylist.OrderByDescending(i = i.Size).ToList(); The problem is that if i sorted it without converting it to "int/double" first -- its not giving right results

    Read the article

  • SELECT TOP N With Two Variables

    - by Ricardo Deano
    Hello all. It's Tuesday morning and I am being thick as (I'm blaming my daughter waking up early this morning!) I have the following example in a SQL table Cust Group Sales A 1 15 A 1 10 A 1 5 A 2 15 A 2 10 A 2 5 B 1 15 B 1 10 B 1 5 B 2 15 B 2 10 B 2 5 What I would like to show is the top 2 products per customer, per group sorted descending by Sales i.e. Cust Group Sales A 1 15 A 1 10 A 2 15 A 2 10 B 1 15 B 1 10 B 2 15 B 2 10 I'm assuming I need to declare two variables, Cust and Group, I'm just not sure how to complete this in one fell swoop. Apologies for the thick question...no excuse. Thanks for any help.

    Read the article

  • python multithread "maximum recursion depth exceed"

    - by user293487
    I use Python multithread to realize Quicksort. Quicksort is implement in a function. It is a recursive function. Each thread calls Quicksort to sort the array it has. Each thread has its own array that stores the numbers needs to be sorted. If the array size is smaller (<10,000). It runs ok. However, if the array size is larger, it shows the "maximum recursion depth exceed". So, I use setrecursionlimit () function to reset the recursion depth to 1500. But the program crash directly...

    Read the article

  • binary search and trio

    - by user121196
    given a large list of alphabetically sorted words in a file,I need to write a program that, given a word x, determines if x is in the list. priorties: 1. speed. 2. memory I already know I can use (n is number of words, m is average length of the words) 1. a tri, time is O(log(n)), space(best case) is O(log(n*m)), space(worst case) is O(n*m). 2. load the complete list into memory, then binary search, time is O(log(n)), space is O(n*m) I'm not sure about the complexity on tri, please correct me if they are wrong. Also are there other good approaches?

    Read the article

  • Create table from a business object with conditional layout

    - by Simon Martin
    I need to generate a table from a List(Of Students). My Student class has properties for AcademicYear, TeachingSet, Surname and Forenames, is sorted in that order and also properties for ID and start date. The table should nest TeachingSets within AcademicYears and then the students within the TeachingSets, as shown in the table I've mocked up at http://www.ifslearning.ac.uk/files/student-table.jpg Using a repeater I get 08-10 students B74394 Mzejb Bsppn 08-10 students B74395 Lbuifsjof Bvti 08-10 students C68924 Epoob Cmpblf 08-10 students D41468 Ipxbse Dbwfz But I need to have 08-10 students - B74394 Mzejb Bsppn - B74395 Lbuifsjof Bvti - C68924 Epoob Cmpblf - D41468 Ipxbse Dbwfz

    Read the article

  • How to do a natural sort on an NSArray?

    - by Cory Imdieke
    I've got an array of objects, and I need them sorted by their "title" key. It's currently working, though it's using an ASCII sort instead of a natural sort. The titles are filenames, so they look like this: file1 file2 file3 ... file10 file11 file12 I'm getting, as you would expect: file1 file10 file11 file12 file2 file3 ... Does anyone know if there is a way built-in to the NSArray sorting functionality to get this natural sorting as opposed to the alphabetical sort? I found some generic algorithms, but I was hoping for something built-in...

    Read the article

  • Updating a TableView with a WebService and Saving to CoreData

    - by jcady
    I am working on a project where I have a table view that is currently updated via a web request that returns XML. I implemented -(int)numberOfRowsInTableView:(NSTableView*)tv and -(id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn*)tableColumn row:(int)row in my XML parsing class, and have the table updated with the data that is pulled down from the server. I want to save the data that is pulled down using Core Data, so that the table can be saved/loaded. Then later on application start when the web request is made, it will only add data that is not already present. (The XML is sorted by release date, so later I will check to see which release dates are not loaded up from the Core Data store, and only load newer entries.) How would I go about implementing this? I am a very new Cocoa developer, but have gone through the entire Hillegass book. Thanks so much.

    Read the article

  • Text rendering blurred in Firefox and Internet Explorer using jQuery

    - by Sixfoot Studio
    Not sure what causes this? If I user slideDown in Firefox the text rendering cuts off the top of the letters before the animation is complete. This is ok in IE. If I then change the animation to use fadeIn instead, the blur does not happen in Firefox but the text is very jagged in IE. From another question I have asked in the past pertaining to animation, the guy told me that I should wrap that which I want to animate in another DIV and animate that instead. This sorted out the jerkiness caused by the padding on the content inside the .animateDiv. Is there a trick to the text rendering as well in jQuery

    Read the article

  • T-SQL Re-Assigning Order Numbering

    - by Meltdown
    Say I have a table with a field called "ordernum" that denotes the order of a given set of rows. Now imagine that I delete one of these rows. What type of query would work best for re-assigning the order numbers so that they remain sequential? Here's an example: id group_id name ordernum active --------------------------------------------------- 0_____0______'Name1'___5__true 1_____0______'Name2'___4__true 2_____0______'Name3'___3__true 3_____1______'Name4'___2__true 4_____1______'Name5'__1__true 5_____1______'Name6'__NULL___false Now if I deleted the column with id='4' how would I reset the values in the 'ordernum' field for that specific group? Is this even possible? Or if I added a new row. (The first time the rows are created they are sorted by date, but then the user has the option to set the order himself.) In my table design I have a column 'active' boolean. If 'active' is set to false, then 'ordernum' is set to NULL. Otherwise it should be given an order number.

    Read the article

  • Sorting By Multiple Conditions in Ruby

    - by viatropos
    I have a collection of Post objects and I want to be able to sort them based on these conditions: First, by category (news, events, labs, portfolio, etc.) Then by date, if date, or by position, if a specific index was set for it Some posts will have dates (news and events), others will have explicit positions (labs, and portfolio). I want to be able to call posts.sort!, so I've overridden <=>, but am looking for the most effective way of sorting by these conditions. Below is a pseudo method: def <=>(other) # first, everything is sorted into # smaller chunks by category self.category <=> other.category # then, per category, by date or position if self.date and other.date self.date <=> other.date else self.position <=> other.position end end It seems like I'd have to actually sort two separate times, rather than cramming everything into that one method. Something like sort_by_category, then sort!. What is the most ruby way to do this?

    Read the article

  • Sort by an object's type

    - by Richard Levasseur
    Hi all, I have code that statically registers (type, handler_function) pairs at module load time, resulting in a dict like this: HANDLERS = { str: HandleStr, int: HandleInt, ParentClass: HandleCustomParent, ChildClass: HandleCustomChild } def HandleObject(obj): for data_type in sorted(HANDLERS.keys(), ???): if isinstance(obj, data_type): HANDLERS[data_type](obj) Where ChildClass inherits from ParentClass. The problem is that, since its a dict, the order isn't defined - but how do I introspect type objects to figure out a sort key? The resulting order should be child classes follow by super classes (most specific types first). E.g. str comes before basestring, and ChildClass comes before ParentClass. If types are unrelated, it doesn't matter where they go relative to each other.

    Read the article

  • What is the right approach when using STL container for median calculation?

    - by sharkin
    Let's say I need to retrieve the median from a sequence of 1000000 random numeric values. If using anything but STL::list, I have no (built-in) way to sort sequence for median calculation. If using STL::list, I can't randomly access values to retrieve middle (median) of sorted sequence. Is it better to implement sorting myself and go with e.g. STL::vector, or is it better to use STL::list and use STL::list::iterator to for-loop-walk to the median value? The latter seems less overheadish, but also feels more ugly.. Or are there more and better alternatives for me?

    Read the article

  • Implement functionality in PHP?

    - by Rachel
    How can we Implement Bisect Python functionality in PHP Implement function bisect_left($arr, $item); as a pure-PHP routine to do a binary-bisection search for the position at which to insert $item into $list, maintaining the sort order therein. Assumptions: Assume that $arr is already sorted by whatever comparisons would be yielded by the stock PHP < operator, and that it's indexed on ints. The function should return an int, representing the index within the array at which $item would be inserted to maintain the order of the array. The returned index should be below any elements in $arr equal to $item, i.e., the insertion index should be "to the left" of anything equal to $item. Search routine should not be linear! That is, it should honor the name, and should attempt to find it by iteratively bisecting the list and comparing only around the midpoint.

    Read the article

< Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >