anchor.diff:  					   {"Date", ["Thu, 10 Feb 2005 14:41:04 GMT"]}
   					  ]),
   
  -    [[<<"Via: via1\r\n">>,
  -      <<"Via: via2\r\n">>],
  -     [<<"Call-Id: call-id-test\r\n">>],
  -     <<"Accept: accept1, accept2\r\n">>,
  -     [<<"Date: Thu, 10 Feb 2005 14:41:04 GMT\r\n">>]] = build_header_binary(BuildHeaderBin_H1),
  +    <<"Via: via1\r\n"
  +     "Via: via2\r\n"
  +     "Call-Id: call-id-test\r\n"
  +     "Date: Thu, 10 Feb 2005 14:41:04 GMT\r\n"
  +     "Accept: accept1, accept2\r\n">> = build_header_binary(BuildHeaderBin_H1),
   
       autotest:mark(?LINE, "build_header_binary/1 - 4"),
       %% test Reason-header without value
  -    [<<"Reason: ", 13, 10>>] = build_header_binary( keylist:from_list([{"Reason", []}]) ),
  -
  +    <<"Reason: ", 13, 10>> = build_header_binary( keylist:from_list([{"Reason", []}]) ),
  +
  +    autotest:mark(?LINE, "build_header_binary/1 - 5"),
  +    %% test the sorting of headers
  +    BuildHeaderBin_H2 = keylist:from_list([{"Call-Id", ["call-id-test2"]},
  +					   {"Via", ["via1", "via2"]},
  +					   {"Route", ["<sip:example.org;lr>"]},
  +                                           {"Accept", ["accept1", "accept2"]},
  +                                           {"Date", ["Thu, 10 Feb 2005 14:41:04 GMT"]},
  +					   {"From", ["Fredrik <sip:testing@example.org>"]}
  +                                          ]),
  +    <<"Via: via1\r\n"
  +     "Via: via2\r\n"
  +     "From: Fredrik <sip:testing@example.org>\r\n"
  +     "Call-Id: call-id-test2\r\n"
  +     "Route: <sip:example.org;lr>\r\n"
  +     "Date: Thu, 10 Feb 2005 14:41:04 GMT\r\n"
  +     "Accept: accept1, accept2\r\n">> = build_header_binary(BuildHeaderBin_H2),
   
       %% test get_tag([String])
       %%--------------------------------------------------------------------
  
positive.code:     %%--------------------------------------------------------------------
      autotest:mark(?LINE, "build_header_binary/1 - 1"),
      %% test single header
      [[<<"Call-Id: call-id-test\r\n">>]] = build_header_binary( keylist:from_list([{"Call-Id", ["call-id-test"]}]) ),
  
      autotest:mark(?LINE, "build_header_binary/1 - 2"),
      %% test multiple values
      [[<<"Via: via1\r\n">>, <<"Via: via2\r\n">>]] = build_header_binary( keylist:from_list([{"Via", ["via1", "via2"]}]) ),
  
      autotest:mark(?LINE, "build_header_binary/1 - 3"),
      %% test more complex case
  
negative.code: %% Records
  %%--------------------------------------------------------------------
  
  %% Used when building binary messages from headers - the headers will be
  %% outputed in the order of the fields in this record
  -record(header_sort, {via		= [],
  		      from		= [],
  		      to		= [],
  		      'call-id'		= [],
  		      cseq		= [],
  		      route		= [],
  		      'record-route'	= [],
  		      rest		= []
  		     }).
  
  %%--------------------------------------------------------------------
  %% Macros
  %%--------------------------------------------------------------------
  