TUTORIAL: NSDictionary Sorting By Value using NSNumbers and NSStrings
Even though this may be a basic topic for some, I struggled with it as usual, so here's what I learned.
Very short, a few screen captures, and a half a page of text total.
As usual shows the source code, and I included the project.
This is what I learned today while hanging around the forum.
Got some great help, and would particularly like to thank RayNewbie for getting me on the right track, and etresoft who tried to help me with the hybrid bindings problem that was eventually solved by xnav, and K T as well for trying to get me on the right path with my myriad of messages...
ABOUT THE DICTIONARIES :
http://www.journey-of-flight.com/bhxcode/how-to/0105_Sort_Array_ByValue/index.php
I really am grateful to those who take the time to help.
Thank You...
Bill Hernandez
Plano, Texas
When I first created the project I was going to use arrays, and as it turned out I used arrays, and a couple of dictionaries, one original and one sorted with the results.
I created a new project, and took some of the screen captures again.
The corrected project, that reflects the correct topic is :
http://www.journey-of-flight.com/bhxcode/how-to/0105_Sort_Dictionary_ByValue/index.php
Sorry for the goof...
Bill Hernandez
Plano, Texas
Similar Messages
-
Hi All,
I already calculated a row(Add Total row) like Gross profit within Group1 (a,b,c,d,e which are sub groups) using Previous and current scope column group values. ex: Gross Profit = a - b. (within group1)
Gross Profit = Previous(Sum(Fields!Trans_amount.Value)) - Sum(Fields!Trans_amount.Value) in Group1
Now, I want to get values for Net income like Net income = a - b - c in Group1. (OR)
Net income = Gross Profit - c in Group1 (Using Gross Profit textbox values using Reportitems!textbox.value). but, values different. Since Expression got new calculation)
Please help me.
Thanks Advance.
- Prem Kumar T D http://www.sharepointbasic.com/Hi Premtd,
As per my understanding, there are group and subgroups in the report, you added total to a group with the expresson: Previous(Sum(Fields!Trans_amount.Value)) - Sum(Fields!Trans_amount.Value). You want to add a text box to the report to calculate Net income
with the expression: Previous(Sum(Fields!Trans_amount.Value)) - Sum(Fields!Trans_amount.Value) - Sum(Fields!Trans_amount.Value). In order to improve the efficiency of troubleshooting, I need to ask several questions:
• “I already calculated a row(Add Total row) like Gross profit within Group1 (a,b,c,d,e which are sub groups)” What’s the meaning of Group1 and subgroup a, b, c, d, e ? Could you please mark Gross profit and the groups in the screenshot?
• How to calculate Net income? Please provide some more detailed information of your requirements. I would be appreciated it if you could provide sample data and clear screenshot of the report.
This may be a lot of information to ask for at one time. However, by collecting this information now, it will help us move more quickly toward a solution.
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu -
Sorting grouped values by month and year within chart
Hello
I have a really tough problem which I can't seam to figure out.
I have a table called SOLAR_RETURN which has 4 columns:
- ID
- USER_ID
- DATUM
- RETURN
On a page I have 3 links, one for showing the information from the database by day, month or year.
The hidden field :P25_DATE_FILTER is being set through the URL when clicking one of the 3 links.
I have a linechart with the following sql statement which pulls the correct data according to the value of :P25_DATE_FORMAT:
select null link, to_char("SOLAR_RETURN"."DATUM", :P25_DATE_FILTER) as label, max("SOLAR_RETURN"."RETURN") as value from "SOLAR_RETURN"
WHERE "SOLAR_RETURN"."USER_ID" = :USER_ID
AND to_char(DATUM, :P25_DATE_FILTER) = decode(:P25_DATE_FILTER,'YYYY',to_char(DATUM, 'YYYY'),'MM-YYYY',to_char(DATUM, 'MM-YYYY'),'DD-MM-YYYY',to_char(DATUM, 'DD-MM-YYYY'))
GROUP BY to_char(DATUM, :P25_DATE_FILTER)
Everything is working great, only the sorting is messed up. I need to sort it so that when :P25_DATE_FORMAT is set to DD-MM-YYYY it will be sorted by year desc, month desc, day desc. If the value would be MM-YYYY it would need to sort by year desc, month desc.
I have tried the following without succes:
ORDER BY to_char(DATUM, :P25_DATE_FILTER) ASC
--> This doesnt cut it since it sorts like this: (for example)
01-2010
02-2010
11-2009
12-2009
Vice versa for DESC
Is there any way that I can sort the grouped values by day, month and year seperately?
Thanks in advance!
MarcHi,
What is data type for column DATUM ?
If it is date did you try ORDER BY DATUM DESC ?
Br,Jari -
Passing values using "Submit" and also transition to another tabstrip
Hi, I am new to VC and have some basic issues in my model.
I have used two layers, the first one for selection of data and the second one to disply the charts, using tabstrips. when I input the data in the first tab and click "Submit" pushbutton, I could not transition automatically to the second which shows the data. I found that onely one action can be set under custom action on the pushbutton. Is there a better way to do?
I could get the relevant documents when I searched. Please let me know how to achieve this. Thanks
KSHi
Follow the steps below - (I am assuming that you are using BI queries in your model & your tabs are as per quarter - one tab for each quarter)
1. Create one radio button & in entry list create static list as 1 - Quarter 1, 2 - Quarter 2 & so on.
2. Now you want plan Vs actual in one graph & Currency in another. So create these reports for each quarter separately, so in all you will have 8 reports (2 for each quarter)
3. IN the layout you have to arrange it vary carefully, you take all the 'Plan Vs Actual' report for all the quarters & arrange them exactly one over the other. Same for Currency reports also.
4. NOw Give visibility condition for each report example - if report is for first quarter then condition will be - bool(if(radio button string=="1",true,false)) & assign the default value in radio button as 1. so that at the time of execution you will get these reports by default.
5. Like wise give condition for all.
6. When you execute this report you will get radio buttons at the top & as you select different buttons differents report will get opened.
7. As you have plased these exactly one over the other, user will not come to know these are different reports.
Try this method, if you have any doubts for this, please do ask me.
Regards
Sandeep -
How to modify an XML values using XSLT and Java
Hi Friends,
I wish to modify a simple xml to another xml using XSLT, please let me know what are the things i need to know to convert the XML to another XML.
If somebody can give a sample code, it will be great...
I wish to do the following sample conversion of XML
<?xml version="1.0" encoding="ISO-8859-1" ?>
<ROOT>
<NAME>TEST1</NAME>
</ROOT>so that the results look like below....
<?xml version="1.0" encoding="ISO-8859-1" ?>
<ROOT>
<NAME>TEST2</NAME>
</ROOT>Notice TEST1 is replaced with TEST2 in the 2nd XML, I wish to get that result...please help.
Thanks and Regards,
JGThanks for your nice reply... do you have a sample code...
-
Line details sort order when using Pick and Pack
Hi,
A customer of mine recently complained (very small complain) that when he used "Per date" as a sort when using Pick & Pack, that the line details where not grouped together by Sales Order Number.
Example:
2008/11/23 SO1001 - Line 1
2008/11/23 SO1013 - Line 3
2008/11/23 SO1001 - Line 2
2008/11/23 SO1001 - Line 4
2008/11/23 SO1021 - Line 1
2008/11/23 SO1001 - Line 5
etc...
Is there a way to sort records on two columns instead of just one? or would there be another workaround this issue?
Thanks
CharlesI think I found my answer, sorting data using the Data/Sort feature allows for sorting on multiple columns.
-
Chinese Charactor sorting in List using Comparator and Collator
I've used Collator.sort method with Locale.TRADITIONAL_CHINESE Locale to sort an ArrayList which contains a list of Chinese charactor. But it seems that the ordering is not based on stroke.
Here is the coding for compare methods whose class implements java.util.Comparator
public int compare(Object obj1, Object obj2){
String string1 = (String)obj1;
String string2 = (String)obj2;
int compareResult = 0;
Locale locale = locale = Locale.TRADITIONAL_CHINESE;
Collator collator = Collator.getInstance(locale);
compareResult = collator.compare(string1, string2);
return compareResult;
Could any one have exprience on it???
Thanks,The resulted sequence
"\u59cb\u6587\u65bc\u6709\u6c0f\u6f22\u7136\u7565\u7fa9\u800c\u81f3\u8a31\u8aaa\u91cd\u97f3"follows the traditional ordering of the Kangxi radicals within the limit of CJK Unified Ideographs.
The following may be more flexible.
import java.util.*;
import java.io.*;
import java.text.*;
public class CharSort implements Comparator{
java.text.RuleBasedCollator collator; // you can set your rules for the instance "collator"
CharSort(){
collator = (RuleBasedCollator)java.text.Collator.getInstance(java.util.Locale.TAIWAN);//try testing various locales
public void doSort(String str) throws java.io.IOException{
java.text.CollationKey[] keys = new java.text.CollationKey[str.length()];
for(int i=0;i<keys.length;i++){
keys[i] = collator.getCollationKey(str.substring(i,i+1));
java.util.Arrays.sort(keys, this);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("cjk.txt"), "UTF8"));
for(int i=0;i<keys.length;i++){
bw.write(keys.getSourceString());
bw.newLine();
bw.close();
public int compare(Object c1, Object c2) throws IllegalArgumentException{
if((c1 instanceof CollationKey) &&(c2 instanceof CollationKey)){
return collator.compare(((CollationKey)c1).getSourceString(), ((CollationKey)c2).getSourceString());
}else throw new IllegalArgumentException();
public boolean equals(Object c1, Object c2){
if(this.compare(c1,c2)==0) return true;
else return false;
public static void main(String[] args) throws java.lang.Exception{
CharSort chSort = new CharSort();
String str = "\u81f3\u6f22\u8a31\u6c0f\u59cb\u6709\u8aaa\u6587\u7136\u91cd\u7fa9\u800c\u7565\u65bc\u97f3";
chSort.doSort(str); -
Missing Value using HashMap and StringTokenizer
class StringToken
String Message = "a b Germany";
HashMap <String,String> map;
StringTokenizer token;
public StringToken()
try
token = new StringTokenize(Message);
map = new HashMap <String,String>();
map.put("a","Adelaide");
map.put("b","Auckland");
while (token.hasMoreToken())
System.out.print (map.get(pesan.nextToken())+" ");
catch(Exception e)
public static void main(String[] args)
new StringToken();
The output like this :
Adelaide Auckland null
What i want like this:
Adelaide Auckland Germany
The problem is,How to display all value of Message? cos There's no Germany key..i want to make some condition like this, if there's no key in the Hashmap, the value still displayed originally..
At my code the problem is, if there's no key in hashmap,output wont display the word..
Thanks Guys...Two options:
1) Instead of
System.out.print(map.get(pesan.nextToken()));do
String token = pesan.nextToken();
String value = map.get(token);
if (value==null) value = token;
System.out.print(value);2) Implement a new Map which provides this behavior.
Cheers -
Get GPS info using Autonomous and CellSite Mode parallelly using MultiThreading
I tried to get the GPS latitude and longitude values using Autonomous and CellSite Mode parallelly using two threads, but while execution only one thread is being active and I get values from only that, the other thread doesn't return any values at all.
Is it possible to retrieve the GPS information using multiple threads running parallelly and also can I display the latitude and longitude values from the threads on the screen with less accuracy rate among the values.
Thanks in advance...Your thread may not get noticed as it is in General Support threads. You may post your thread in Java Development to get faster response.
Ron
Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up Blackberry Battery Saving Tips | Follow me on Twitter -
Multiple Values using if-- inlist
Hi,
How to pass multiple values using inlist and if
=if([Plant] InList("2010";"2012";"2014";"2016";"2018") ; xyz") ElseIf([Plant] InList("2020";"2022";"2024";"2026";"2028"); "pqr") ElseIf
([Plant] InList("2030";"2032";"2034");"abc") else ([dgh])
i am getting error in this please correct it
Thanks & Regards,
VinayUse "Then " to resolve above error.
For example :
=If([Year]InList("2001";"2002";"2003")) Then "Y" ElseIf ([Year]InList("2005";"2006";"2007")) Then "yy" Else ([Year])
Regards,
Pranay -
My spreadsheet looks like this:
Monday Tuesday Wednesday
Name 1 OFF 4:30 PM 4:30 PM
Name 2 5 PM OFF 4:30 PM
Name 3 4:30 PM 5 PM OFF
Name 4 4 PM OFF OFF
I would like to create a spreadsheet for each day that will display the values sorted by time, as follows (e.g. Monday):
Name In Time
Name 4 4 PM
Name 3 4:30 PM
Name 2 5 PM
Any help would be greatly appreciated. Thanks!Here's an example, using the provided data:
I've set the alignment on Main to Automatic (except for row 1) to distinguish between numeric and quasi numeric values (aligned right) and text (aligned left). This is a visual aid to developing the table, and would likely be changed for appearance in the end version.
Columns E, F and G of Main are index columns listing the RANK of numeric/date and time values in columns A, B and C respectively. Text values cause RANK to throw an error, which is caught by IFERROR, which returns a value of 999, chosen to be well above any of the RANK values returned. A small amount ( ROW()/100000 ) is added to each result to prevent duplicate results is cases like column D, where duplicate times appear.
Formula: Main::E2: =IFERROR(RANK(B2,B,1),999)+ROW()/100000
Fill down the column, and right to column G.
These columns may be hidden.
The three daily columns use a single formula each, revised to match the index columns from which they determine the row containing each piece of data to be copied, and to match the columns from which they retrieve that data. The formulas from row 2 of these tables are listed here in the order (left to right) that they are used in the second row of tables above. Parts that are edited from one formula to another are shown in bold.
=IF(SMALL(Main :: $E,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$E,ROW()-1),Main :: $E,0)-1,0))
=IF(SMALL(Main :: $E,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$E,ROW()-1),Main :: $E,0)-1,1))
=IF(SMALL(Main :: $F,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$F,ROW()-1),Main :: $F,0)-1,0))
=IF(SMALL(Main :: $F,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$F,ROW()-1),Main :: $F,0)-1,2))
=IF(SMALL(Main :: $G,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$G,ROW()-1),Main :: $G,0)-1,0))
=IF(SMALL(Main :: $G,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$G,ROW()-1),Main :: $G,0)-1,3))
Each of the formulas is filled down its column.
Each of the functions used is described in the iWork Formulas and Functions User Guide, a useful resource to have on hand when you are writing (or attempting to 'decode') Numbers formulas, The guide (and the Numbers '09 User Guide) may be downloaded from the Help menu in Numbers '09.
Regards,
Barry -
Sending and receiving values using web services vi
hi trying to receive values values using the webservices vi 's, but im facing same conversion errors. im sending my project and an image of the problem can anyone help me on this?
Attachments:
TZID.zip 21 KB
labviewscrn.JPG 126 KBHi,
Here is a global tutorial about Web Services :
http://zone.ni.com/devzone/cda/tut/p/id/7350
There are exemples at the end of the document : webservicesdemo.zip
Please check the instruction for using web services given in the Readme.doc, it could be the source of your problem.
Also, mind that you need the same language for you labVIEW version than the one used to create the Web service VIs.
Regards,
Rémi M.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
>> Les présentations NIDays 2010 déjà disponibles au téléchargement ! -
Dear Experts,
i am getting the below error when i was giving * (Star) to view all the items in DB
[Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. 'Items' (OITM) (OITM)
As i was searching individually it is working fine
can any one help me how to find this..
Regards,
Meghanath.SDear Nithi Anandham,
i am not having any query while finding all the items in item master data i am giving find mode and in item code i was trying to type *(Star) and enter while typing enter the above issue i was facing..
Regards,
Meghanath -
hi Experts,
while running SQL Query i am getting an error as
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. for the query
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
T2.LineText
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,T2.LineText
how to resolve the issueDear Meghanath,
Please use the following query, Hope your purpose will serve.
select T1. Dscription,T1.docEntry,T1.Quantity,T1.Price ,
CAST(T2.LineText as nvarchar (MAX))[LineText]
from OQUT T0 INNER JOIN QUT1 T1 ON T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
QUT10 T2 ON T1.DocEntry = T2.DocEntry --where T1.DocEntry='590'
group by T1. Dscription,T1.docEntry,T1.Quantity,T1.Price
,CAST(T2.LineText as nvarchar (MAX))
Regards,
Amit -
How to pick max value from a column of a table using cursor and iteration
Hello Everybody
I have a table loan_detail
and a column in it loan_amount
now i want to pick values from this table using cursor and then by using iteration i want to pick max value from it using that cursor
here is my table
LOAN_AMOUNT
100
200
300
400
500
5600
700i was able to do it using simple loop concepts but when i was trying to do this by using cursor i was not able to do it .
Regards
PeeyushSQL> SELECT MAX(sal) Highest_Sal,MIN(sal) Lowest_Sal FROM emp;
HIGHEST_SAL LOWEST_SAL
5000 800
SQL> set serverout on
SQL> DECLARE
2 TYPE tmp_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3 sal_tbl tmp_tbl;
4 CURSOR emp_sal IS
5 SELECT sal FROM emp;
6 counter INTEGER := 1;
7 BEGIN
8 FOR i IN emp_sal LOOP
9 sal_tbl(i.sal) := counter;
10 counter := counter + 1;
11 END LOOP;
12 DBMS_OUTPUT.put_line('Lowest SAL:' || sal_tbl.FIRST);
13 DBMS_OUTPUT.put_line('Highest SAL:' || sal_tbl.LAST);
14 END;
15 /
Lowest SAL:800
Highest SAL:5000
PL/SQL procedure successfully completed.
SQL> Even smaller
SQL> DECLARE
2 TYPE tmp_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3 sal_tbl tmp_tbl;
4 CURSOR emp_sal IS
5 SELECT sal FROM emp;
6 counter INTEGER := 1;
7 BEGIN
8 FOR i IN emp_sal LOOP
9 sal_tbl(i.sal) := 1;
10 END LOOP;
11 DBMS_OUTPUT.put_line('Lowest SAL:' || sal_tbl.FIRST);
12 DBMS_OUTPUT.put_line('Highest SAL:' || sal_tbl.LAST);
13 END;
14 /
Lowest SAL:800
Highest SAL:5000
PL/SQL procedure successfully completed.
SQL> Edited by: Saubhik on Jan 5, 2011 4:41 PM
Maybe you are looking for
-
Set parameter and call transaction
Hi. To use the call transaction with the skip first screen option we have to use the set parameter statement. Depending on the PID which the technical specs of the fields contain, it is possible to preset these values. My query is that if the screen
-
Watermarking for images on mobileme
Hi I have my various albums all sorted in Aperture, and published them accordingly to Mobileme. My question is how can I add a watermark to the images that are displayed on Mobileme? I know I can set a Web Export preset to add watermarks, but this wo
-
OVS Buttons with wrong Label on Portal
Hello, I have a Web Dypro application that uses an OVS. The OVS works fine and looks fine when I test on my locally installed Application Server. But when I run the application on the Portal ( the OVS opens fine and does its functionality) the OVS Bu
-
i have created a template and on the side i have a list of links that i change regularly (not in editable region). I dont want to upload all my files everytime i change a link in the list, so i thought a library item would be the go. However, when i
-
How to change the color of a basic graphic texture?
The basic graphic texture pattern is black by default. I'm looking for a way to change the color of the black lines that create the texture. I read How do I change the color of Basic Graphic Lines? However, I am unable to select the black pattern lin