advice Question

Sort 2 dim String table + search for string

Avatar of Tore
ToreFlag for Norway asked on
8 Comments1 Solution18 ViewsLast Modified:

Trying to figure out how to sort a 2 dimensional String table, but it seems like all suggestions on the web is avoiding the problem. 

Arrays.sort(...) does not work well on string tables

was thinking of Arrays.binarySearch

Do i have to in some way rely on ArrayList ?

or am I barking up the wrong tree ?

package no.test.basic.stringtable;
import java.util.Arrays; public class TwoDimStringTable {     public static void main(String [] args) {         String[][] sTabell = new String[8][2];         sTabell[0][0] =  "Ola";         sTabell[1][0] =  "var";         sTabell[2][0] =  "fra";         sTabell[3][0]=   "Sandefjord";         sTabell[4][0] =  "Han";         sTabell[5][0] =  "var";         sTabell[6][0] =  "lettmatros";         sTabell[7][0] =  "ombord!";         sTabell[0][1] =  "Ola";         sTabell[1][1] =  "kunne";         sTabell[2][1] =  "engelsk";         sTabell[3][1]=   "ei";         sTabell[4][1] =  "men";         sTabell[5][1] =  "han";         sTabell[6][1] =  "klarte";         sTabell[7][1] =  "seg";                 for (int i = 0; i <= sTabell.length-1; i++) {             System.out.println(sTabell[i][0] + "  " + sTabell[i][1]);         }  // what next for sorting // what next for searching for the string "klarte" to get position of element         }   }

Open in new window

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 8 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 8 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004