Thanks Sergio, Benja and PhiLho.
The first code, from Sergio, is easier for me to understand, but it produces an odd result in the last comparison:
comparing... The tree is tall
found the string 'tall' from words2, on 'The tree is tall'
comparing... there are two cats in the wall
found the string 'two' from words, on 'there are two cats in the wall'
found the string 'cats' from words2, on 'there are two cats in the wall'
comparing... third is three
found the string 'three' from words, on 'third is three'
comparing... no use for a car here
found the string 'use' from words2, on 'no use for a car here'
comparing... five empty houses
found the string 'use' from words2, on 'five empty houses'
found the string 'five' from words, on 'five empty houses'
There is no "use" in "five empty houses".
Benja's code worked fine, but i need some help to understand it. Questions:
1- The noLoop() at the end of setup makes draw() run only once? I would have placed it at the end of draw...
2-
ArrayList<ArrayList<String>> sortedStrings;
well this i've never seen before, so it is an arraylist of arraylists of strings? The cleverness here is that this way, as in words[][], we can interact with both at the same loop, right? Good idea!
But, this:
// create two-dimensional arraylist for sorted Strings
sortedStrings = new ArrayList<ArrayList<String>>();
for (int i = 0; i< words.length; i++) {
sortedStrings.add(new ArrayList<String>());
}
Is it just adding empty (null?) elements to the array list? If so, why is this necessary? I mean an arraylist can grow as needed right?
3 The access seems weird, i mean i need to use get() even to add(). Correct?
sortedStrings.get(j).add(toBeCompared[i]);
so to reproduce the line 2darray[100][88] = 1000; i need to do 2darraylist.get(100).get(88) =1000; ?
Any way that is working!! Thanks again, gonna implement it on the sketch now :-)
A last question, in this post, answering me, PhiLho sad that a hashMap is faster for comparison. I don't think i would need the fastest way, but would that be an approach fro this matter?
Thanks you all.
vk