Re: Sorting a multidimensional array by multiple keys



If you want a good answer you have to give me/us more details, and an
example too.

OK, here is some example data:

reaction is BUT by the
sodium , BUT it is
sea , BUT it is
this manner BUT the dissolved
pattern , BUT it is
rapid , BUT it is

As each line consists of 5 words, I would break up the data into an array
of five-field-arrays (Would you use lists or tuples or a combination in
Python?). The word "BUT" would be in the middle, with two fields/words
left and two fields/words right of it. I then want to sort this list by

- field 3
- field 4
- field 1
- field 0

in this hierarchy. This is the desired result:

pattern , BUT it is
rapid , BUT it is
sea , BUT it is
sodium , BUT it is
reaction is BUT by the
this manner BUT the dissolved

The first 4 lines all could not be sorted by fields 3 & 4, as they are
identical ("it", "is"), so they have been sorted first by field 1 (which
is also identical: ",") and then by field 0:

pattern
rapid
sea
sodium

I hope I have explained this in an understandable way. It would be cool
if you could show me how this can be done in Python!

Regards,
Rehceb
.



Relevant Pages

  • Re: Sorting a multidimensional array by multiple keys
    ... sodium, BUT it is ... sea, BUT it is ... this manner BUT the dissolved ... pattern, BUT it is ...
    (comp.lang.python)
  • Re: Disposing of sodium metal
    ... Any ideas on how to safely dispose of this? ... Standard Procedure is to disolve in alcohol, and make sodium methoxide ... the standard procedure is to add it to n-butanol and stir until ... no more reaction is observed. ...
    (sci.chem)
  • Re: One for lil ol wine drinker Alan
    ... reaction every time he takes it. ... I'd increased my sodium consumption anyway by snorting ... ranitidine is crap at controlling my acid reflux whereas famotidine ... now I've returned to the famotidine I've been able to reduce ...
    (alt.support.diabetes)
  • Re: general question on salts
    ... Sodium citrate from the sodium carbonate reaction gives you more powder than from the sodium hydroxide reaction, at least I think it does. ... There is a possibility that the impurities in your reagents may cause slightly different crystalline forms. ... eg Try adding 1 part of meths to 1 part of water in a measuring jug. ...
    (sci.chem)
  • Re: (rec.pyro) Making copper oxychloride
    ... Preparing chemicals for pyrotechnic use by double-decomposition ... reactions that involve sodium compounds is a bad idea. ... from the desired reaction product. ...
    (rec.pyrotechnics)