Index: TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java
===================================================================
--- TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java	(revision 4002)
+++ TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/preferences/TextsBalancePreferencePage.java	(revision 4003)
@@ -52,7 +52,6 @@
 	@Override
 	public void createFieldEditors() {
 
-		
 		// Charts rendering
 		Composite chartsTab = SWTChartsComponentsProvider.createChartsRenderingPreferencesTabFolderComposite(this.getFieldEditorParent());
 		
@@ -64,14 +63,14 @@
 //		method.getTextControl(getFieldEditorParent()).setToolTipText("Method (1: uses CQL to solve matches, 2 uses corpus struct indexes, 2 is faster!)");
 //		this.addField(method);
 		
-		String[][] methods = new String[2][2];
-		for(int i = 0; i < 2; i++) {
-			methods[i][0] = String.valueOf(i + 1);
-			methods[i][1] = String.valueOf(i + 1);
-		}
+//		String[][] methods = new String[2][2];
+//		for(int i = 0; i < 2; i++) {
+//			methods[i][0] = String.valueOf(i + 1);
+//			methods[i][1] = String.valueOf(i + 1);
+//		}
 
-		this.addField(new ComboFieldEditor(TextsBalancePreferences.METHOD, Messages.Method, methods, chartsTab));
-		this.addField(new BooleanFieldEditor(TextsBalancePreferences.GROUP_BY_TEXTS, Messages.GroupByWords, chartsTab));
+		//this.addField(new ComboFieldEditor(TextsBalancePreferences.METHOD, Messages.Method, methods, chartsTab));
+		this.addField(new BooleanFieldEditor(TextsBalancePreferences.COUNT_TEXTS, Messages.GroupByWords, chartsTab));
 		
 		// other shared preferences
 		SWTChartsComponentsProvider.createChartsRenderingPreferencesFields(this, chartsTab);
Index: TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/TextsBalanceEditor.java
===================================================================
--- TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/TextsBalanceEditor.java	(revision 4002)
+++ TXM/trunk/bundles/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/TextsBalanceEditor.java	(revision 4003)
@@ -47,7 +47,7 @@
 	/**
 	 * Group by texts or not.
 	 */
-	@Parameter(key=TextsBalancePreferences.GROUP_BY_TEXTS)
+	@Parameter(key=TextsBalancePreferences.COUNT_TEXTS)
 	protected Button groupByTexts;
 	
 	
Index: TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/preferences/TextsBalancePreferences.java
===================================================================
--- TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/preferences/TextsBalancePreferences.java	(revision 4002)
+++ TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/preferences/TextsBalancePreferences.java	(revision 4003)
@@ -14,8 +14,8 @@
 public class TextsBalancePreferences extends ChartsEnginePreferences {
 
 	
-	public static final String GROUP_BY_TEXTS = "group_by_texts"; //$NON-NLS-1$
-	public static final String METHOD = "method"; //$NON-NLS-1$
+	public static final String COUNT_TEXTS = "group_by_texts"; //$NON-NLS-1$
+	//public static final String METHOD = "method"; //$NON-NLS-1$
 	
 	
 	/**
@@ -35,11 +35,10 @@
 		super.initializeDefaultPreferences();
 		
 		Preferences preferences = this.getDefaultPreferencesNode();
-		preferences.putBoolean(GROUP_BY_TEXTS, true);
-		preferences.putInt(METHOD, 2);
-		
+		preferences.putBoolean(COUNT_TEXTS, false);
 		preferences.put(STRUCTURAL_UNIT, "text");
-
+		//preferences.putInt(METHOD, 2);
+		
 		// to disable the functionality
 		TXMPreferences.setEmpty(this.getPreferencesNodeQualifier(), ChartsEnginePreferences.SHOW_GRID);
 	}
Index: TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/functions/TextsBalance.java
===================================================================
--- TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/functions/TextsBalance.java	(revision 4002)
+++ TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/functions/TextsBalance.java	(revision 4003)
@@ -8,11 +8,11 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 
 import org.txm.chartsengine.core.results.ChartResult;
 import org.txm.core.results.Parameter;
-import org.txm.core.results.TXMParameters;
 import org.txm.searchengine.cqp.AbstractCqiClient;
 import org.txm.searchengine.cqp.CQPSearchEngine;
 import org.txm.searchengine.cqp.NetCqiClient;
@@ -21,10 +21,11 @@
 import org.txm.searchengine.cqp.corpus.QueryResult;
 import org.txm.searchengine.cqp.corpus.StructuralUnit;
 import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
-import org.txm.searchengine.cqp.corpus.query.Match;
 import org.txm.searchengine.cqp.corpus.query.CQLQuery;
+import org.txm.searchengine.cqp.corpus.query.Match;
 import org.txm.textsbalance.core.preferences.TextsBalancePreferences;
 import org.txm.utils.TXMProgressMonitor;
+import org.txm.utils.io.IOUtils;
 import org.txm.utils.logger.Log;
 
 /**
@@ -36,7 +37,7 @@
  */
 public class TextsBalance extends ChartResult {
 	
-	HashMap<Comparable[], Integer> dataset;
+	LinkedHashMap<Comparable<?>[], Integer> dataset;
 	
 	protected String propertyName;
 	protected List<String> values;
@@ -45,7 +46,6 @@
 	
 
 	protected int method;
-
 	
 	/**
 	 * Structural unit to explore.
@@ -62,7 +62,7 @@
 	/**
 	 * Group by texts or not.
 	 */
-	@Parameter(key=TextsBalancePreferences.GROUP_BY_TEXTS)
+	@Parameter(key=TextsBalancePreferences.COUNT_TEXTS)
 	protected boolean countTexts;
 	
 
@@ -119,7 +119,7 @@
 		
 		monitor.setTask("Computing balance with metadata propertyName = " + this.structuralUnitProperty + ", structural unit = " + this.structuralUnit.getName() + " and groupByTexts = " + this.countTexts); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 		try {
-			this.dataset = new HashMap<Comparable[], Integer>();
+			this.dataset = new LinkedHashMap<Comparable<?>[], Integer>();
 			
 			StructuralUnitProperty p = this.structuralUnitProperty;
 			this.values = p.getValues();
@@ -258,7 +258,7 @@
 	/**
 	 * @return the dataset
 	 */
-	public HashMap<Comparable[], Integer> getDataset() {
+	public HashMap<Comparable<?>[], Integer> getDataset() {
 		return dataset;
 	}
 
@@ -270,7 +270,6 @@
 		return (CQPCorpus) this.parent;
 	}
 
-
 	/**
 	 * @return the propertyName
 	 */
@@ -278,7 +277,6 @@
 		return propertyName;
 	}
 
-
 	/**
 	 * @return the values
 	 */
@@ -286,7 +284,6 @@
 		return values;
 	}
 
-
 	/**
 	 * @return the fMin
 	 */
@@ -294,7 +291,6 @@
 		return fMin;
 	}
 
-
 	/**
 	 * @return the fMax
 	 */
@@ -302,14 +298,16 @@
 		return fMax;
 	}
 
-
 	@Override
 	public boolean _toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
-		// TODO Auto-generated method stub
-		return false;
+		
+		StringBuffer buffer = new StringBuffer();
+		for (Comparable<?>[] k : dataset.keySet()) {
+			buffer.append(txtseparator+k[1]+txtseparator+colseparator+txtseparator+dataset.get(k)+txtseparator+"\n");
+		}
+		return IOUtils.write(outfile, buffer.toString());
 	}
 
-
 	@Override
 	public void clean() {
 		// TODO Auto-generated method stub
Index: TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/chartsengine/jfreechart/JFCTextsBalanceSpiderChartCreator.java
===================================================================
--- TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/chartsengine/jfreechart/JFCTextsBalanceSpiderChartCreator.java	(revision 4002)
+++ TXM/trunk/bundles/org.txm.textsbalance.core/src/org/txm/textsbalance/core/chartsengine/jfreechart/JFCTextsBalanceSpiderChartCreator.java	(revision 4003)
@@ -25,7 +25,7 @@
 		JFreeChart chart = null;
 		
 		// Creates an empty dataset
-		HashMap<Comparable[], Integer> data = textsBalance.getDataset();
+		HashMap<Comparable<?>[], Integer> data = textsBalance.getDataset();
 		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
 		
 		plot = new SpiderWebPlot(dataset);
@@ -63,12 +63,12 @@
 		chart.setNotify(false);
 		
 		// updating data set
-		HashMap<Comparable[], Integer> data = textsBalance.getDataset();
+		HashMap<Comparable<?>[], Integer> data = textsBalance.getDataset();
 		DefaultCategoryDataset dataset = (DefaultCategoryDataset) ((SpiderWebPlot) chart.getPlot()).getDataset();
 		dataset.clear();
 		
-		Set<Comparable[]> keys = data.keySet();
-		Iterator<Comparable[]> it = keys.iterator();
+		Set<Comparable<?>[]> keys = data.keySet();
+		Iterator<Comparable<?>[]> it = keys.iterator();
 		while (it.hasNext()) {
 			Comparable[] key = it.next();
 			Integer value = data.get(key);
