Library files: Lines should be explicitly ordered

Description

When doing changes to a footprints the order of lines in the .kicad_mod file might change unexpectedly. That is mostly an issue when doing library review work. A lots of changes could be checked/reviews by just looking at the git diff. But that becomes really hard when lines are shuffled.

Example: there are actually no changes in this diff image

My proposal is to set an explicit rule to sort items:

  • Sort by type of item (pad, fp_line, fp_arc, ...)
  • Sort by layers
  • Sort by coordinates (center for circles and arc, start-point for lines, ...)

Any string-based sort should not depend on the system-locale.

Steps to reproduce

  1. Open Package_TO_SOT_THT.pretty/SOD-70_P2.54mm.kicad_mod
  2. Mark the right part of the footprint, cut (CTRL-X, click origin)
  3. Paste (CTRL-V, click origin)
  4. save file

KiCad Version

Application: LibEdit
Version: 5.1.6+dfsg1-1~bpo10+1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Platform: Linux 4.19.0-9-amd64 x86_64, 64 bit, Little endian, wxGTK
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
    Boost: 1.67.0
    OpenCASCADE Technology: 7.3.0
    Curl: 7.64.0
    Compiler: GCC 8.3.0 with C++ ABI 1013
Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=ON
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=ON
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=OFF
    KICAD_USE_OCC=ON
    KICAD_SPICE=ON
Edited by cpresser