how To sort a hashmap using its keys and/or values

To sort a hashmap using its keys :- Dump the HashMap into a TreeMap: Map yourMap= new HashMap(); // put some tuples in yourMap … Map sortedMap = new TreeMap(yourMap); To sort a hashmap using its values :- public HashMap getSortedMap(HashMap hmap) { HashMap map = new LinkedHashMap(); List mapKeys = new ArrayList(hmap.keySet()); List mapValues = new… Continue reading how To sort a hashmap using its keys and/or values


[Java] Reverse ordering a TreeMap

TreeMap is a Map that keep the element in the natural order of the key. The order can be changed providing to the contructor of the TreeMap a Comparable. So you can implement your custom one for more specific tasks. However if you only need a reverse order, you can easily use the beautifulCollections class with his reverseOrder(). Here is a… Continue reading [Java] Reverse ordering a TreeMap


get post by title

function get_post_by_title($page_title) { global $wpdb; $post = $wpdb->get_var( $wpdb->prepare( “SELECT ID FROM $wpdb->posts WHERE post_title = %s “, $page_title )); if ( $post ) { $post= get_post($post, $output); //print_r($post); $language=get_bloginfo(‘language’); if($post->post_type==”research”){ $research_language= get_post_meta($post->ID, ‘language’, true); // print $research_language. ” “.$language;print “<hr>”; if($research_language!=$language) return false; else return true; } } // return null; }

java · jdbc · mysql

SqlExecuter vs JDBC

public class CmdExec { public static void main(String argv[]) { executeSql(); } private static void executeSql() { final class SqlExecuter extends SQLExec { public SqlExecuter() { Project project = new Project(); project.init(); setProject(project); // setTaskType(“sql”); setTaskName(“sql”); } } SqlExecuter executer = new SqlExecuter(); executer.setSrc(new File(“/home/admin/Obama/scripfile.sql”)); executer.setDriver(“com.mysql.jdbc.Driver”); executer.setPassword(“root”); executer.setUserid(“root”); executer.setUrl(“jdbc:mysql://localhost:3306/Central_Share”); executer.execute(); } } //add dependency <dependency>… Continue reading SqlExecuter vs JDBC