Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6851

Re: How to sort elements from a two-dimensional list

From A Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to sort elements from a two-dimensional list
Date 2011-11-30 12:07 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jb5699$je0$1@smc.vnet.net> (permalink)
References <jb4pga$gts$1@smc.vnet.net>

Show all headers | View raw


Hi,

 > I have a list as follows:
 > data={{1,0.0000317057}, {1,0.0000156821}, {1,0},{1, 
00000234685},{1,0.000025413}, {1., 0.0000249271},{1, 0.0000210391}, 
{1.,0.0000181187},{1,0.0000210391},{2, 0.000025413}, 
{2.,0.000024441},{2,0.0000224955}, {2,0.0000239548}, 
{2,0.0000234685},{2,0.0000215261},{2,0.0000132381},{2,0.0000346042},{2,0.0000336413},{3,0.0000355749}, 
{3,0.0000302568},{3,0.0000297722},{3, 0.000025413}, 
{3,0.0000239548},{3,0.0000268658}, {3,0.0000239548}, {3,0.0000273512}, 
{3., 0.0000273512}, {3., 0.0000142161}, {4,0.0000190941}};
 >
 > I'd like to know how to reduce the number of terms of the list to 
avoid the terms on the right side {xi,..} to be repeated.
 >

you could use Union, but probably this is even more adequat:

DeleteDuplicates[data]

since you are comparing real numbers, you might want to use a more 
elaborate test, e.g. something like:

DeleteDuplicates[data,
  And[Abs[#1[[1]] - #2[[1]]] < 0.5, Abs[#1[[2]] - #2[[2]]] < 10^-6] &]

hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

How to sort elements from a two-dimensional list Pippo <dinodeblasio@yahoo.it> - 2011-11-30 08:28 +0000
  Re: How to sort elements from a two-dimensional list A Retey <awnl@gmx-topmail.de> - 2011-11-30 12:07 +0000

csiph-web