Quantcast
Channel: Zumbrennen Gyan
Viewing all articles
Browse latest Browse all 10

Sort list of tuples deliberation locale

$
0
0

Q1.Sort list of tuples deliberation locale

 

 

 

Apparently PostgreSQL 8.4 and Ubuntu 10.04 can't hoop a updated proceed to arrange W and V for Swedish alphabet. That is, it's still organization them as a same minute like this :

  • Wa
  • Vb
  • Wc
  • Vd

it should be :

  • Vb
  • Vd
  • Wa
  • Wc

I need to method this justly for a Python/Django website I'm building. we have attempted several ways to only method a list of tuples combined from a Django QuerySet controlling *values_list*. But given it's Swedish also å, ä and ö letters needs to be justly ordered. Now we have presumably one or a other proceed both not both..

list_of_tuples = [ ,  ,  ,  ,  ,  ,  ]    print '########## Ordering One ##############'  ordered_list_one = sorted ))  for vigilant in ordered_list_one:      print item[0]    print '########## Ordering Two ##############'  locale.setlocale   list_of_names = [u'Wa', u'Vb', u'Wc', u'Vd', u'Öa', u'äa', u'Åa']  ordered_list_two = sorted   for vigilant in ordered_list_two:      print item

The examples gives:

########## Ordering One ##############  Vb  Vd  Wa  Wc  äa  Åa  Öa  ########## Ordering Two ##############  Wa  Vb  Wc  Vd  Åa  äa  Öa

Now, What we wish is a multiple of these so that both V/W and å,ä,ö organization are correct. To be some-more precise. we wish Ordering One to honour locale. By afterwards controlling a second vigilant in any tuple we could fetch a repremand vigilant in Django.

I'm starting to doubt that this will be possible? Would upgrading PostgreSQL to a newer chronicle that handles collations improved and afterwards use tender SQL in Django be possible?

 

 

Answer:

 

 

 

When controlling LC_ALL=sv_SE.UTF-8 sort on your instance on Ubuntu-10.04, it comes out with Wa before Vb , so Ubuntu does not seem to establish with a "new way". Since PostgreSQL relies on a handling component for this, it will act only a same as a OS given a same lc_collate.

There is indeed a patch in debian glibc associated to this sole arrange issue: http://sourceware.org/bugzilla/show_bug.cgi?id=9724 But it was objected to and not accepted. If we wholly need this function on a component we administer, we can still ask a change of a patch to /usr/share/i18n/locales/sv_SE and transform a se_SV locality by controlling locale-gen sv_SE.UTF-8. Or improved yet, emanate your possess choice locality subsequent from it to prevaricate messing with a original.

 

 

Q2.What is a use of pragma formula domain and information section?

 

 

 

What accurately will occur to a information shred and calm shred if we use a next twin lines in my c source formula file?

#pragma CODE_SECTION   #pragma DATA_SECTION 

 

 

Answer:

 

 

 

Source : http://hi.baidu.com/jevidyang/blog/item/6d4dc436d87e3a300b55a918.html

Note: #pragma is compiler specific, so syntax competence change for your compiler.

The DATA_SECTION pragma allocates space for a representation in a domain called domain name. The syntax for a pragma in C could be:

#pragma DATA_SECTION  ;

The syntax for a pragma in C++ could be:

#pragma DATA_SECTION  ;

The DATA_SECTION pragma is useful if we have information objects that we wish to couple into an area removed from a .bss section.


The CODE_SECTION pragma allocates space for a func in a domain named domain name. The CODE_SECTION pragma is useful if we have formula objects that we wish to couple into an area removed from a .text section. The syntax of a pragma in C could be:

#pragma CODE_SECTION  

The syntax of a pragma in C++ could be:

#pragma CODE_SECTION  

 

 

 


Viewing all articles
Browse latest Browse all 10

Trending Articles