Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Random sorting divided in lists

Thread Tools

Random sorting divided in lists

ebotelho ebotelho is offline
Junior Member
Join Date: Aug 2011
Posts: 1
Hello, I'm trapped in a situation where I can't go any further. I have a list of names of which I want to divide into lists after being randomly sorted. For example:
Names: John, Paul, Jenna, Izabela; of which I choose to divide into four lists. That should result into something like this:

List 1:

List 2:

List 3:

List 4:

Of course, there will be a list of names. I am far from an experienced developer and I use an auxiliary class to help me do some stuff. My progress so far is this:

public static void sortNames() {
FILE arquivo = new FILE(FILE.INPUT, "nomes.txt");
String [] lista = new String [countNames()];
String linha;
String temp;

linha = arquivo.readln();
for (int i=0; i<countNames(); i++) {
lista [i] = linha;
linha = arquivo.readln();

//randomizar aqui

int numero = IO.readint("Quantas listas? ");
int qtd = countNames()/numero;
if (qtd < 1) {
IO.println("Nomes insuficientes para tantas listas.");
else {
int p=0;
IO.println("Distribuindo "+countNames()+" em "+numero+" listas.");
IO.println("Serão "+qtd+" nomes por lista.");
IO.pause("Pressione ENTER");
for (int a=0; a<numero; a++) {
IO.println("Lista "+(a+1));
for (int i=0; i<qtd; i++) {


And it is in portuguese, I suppose, though, you can understand pretty much of it.
The critical point is in bold. Any suggestions to make this work? Thanks a bunch.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Help with sorting lists of lists Chris Weisiger Perl Misc 7 10-14-2004 01:42 PM
Sorting lists of lists... JustSomeGuy C++ 0 06-17-2004 05:44 PM
Are clock and divided clock synchronous? Valentin Tihomirov VHDL 11 10-28-2003 01:18 PM