mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2022-06-01, 21:16   #1
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

2·19·41 Posts
Default sorting sieve export

I try for hours and try countless options / combinations but never got 100% what I need ( and ask for help here)

Using sort command under win

So input file is (fake data)

Quote:
100156363476569 | 555*2^721991+1
100210790671219 | 111*2^483289+1
10133084529481 | 333*2^546934+1
101755669569157 | 111*2^479221+1
102599598829447 | 222*2^66533+1
102765600059849 | 555*2^1040951+1
I would like to sort file by k then by exponent so results should be like this

Quote:
101755669569157 | 111*2^479221+1
100210790671219 | 111*2^483289+1
102599598829447 | 222*2^66533+1
10133084529481 | 333*2^546934+1
100156363476569 | 555*2^721991+1
102765600059849 | 555*2^1040951+1
pepi37 is online now   Reply With Quote
Old 2022-06-01, 23:17   #2
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

B9716 Posts
Default

Try this:
- your factors file is "test.txt"
- create awk file "listsort.awk" with code
Code:
{
  gsub(/*2\^/," ",$3)
  gsub(/+1/,"",$3)
  gsub(/-1/,"",$3)
  printf "%20s | %9s %15s\n",$1,substr($3,1,index($3," ")-1),substr($3,index($3," ")+1) >>"test.res"
}
- create batch "listsort.bat" with
Code:
gawk -f listsort.awk test.txt
sort /+23 test.res >test.srt
del test.res >nul
Your example result file "test.srt" looks like
Code:
     101755669569157 |       111          479221
     100210790671219 |       111          483289
     102599598829447 |       222           66533
      10133084529481 |       333          546934
     100156363476569 |       555          721991
     102765600059849 |       555         1040951
Perhaps some changes needed if length of k- or n-values are longer than given in the printf-line.
kar_bon is offline   Reply With Quote
Old 2022-06-01, 23:39   #3
Xyzzy
 
Xyzzy's Avatar
 
Aug 2002

204458 Posts
Default

You don't want to hear this, but this is why we use Linux.
Code:
$ cat file
100156363476569 | 555*2^721991+1
100210790671219 | 111*2^483289+1
10133084529481 | 333*2^546934+1
101755669569157 | 111*2^479221+1
102599598829447 | 222*2^66533+1
102765600059849 | 555*2^1040951+1

$ cat file | sort -t "^" -k2,2n | sort -t "|" -k2,2n -s
101755669569157 | 111*2^479221+1
100210790671219 | 111*2^483289+1
102599598829447 | 222*2^66533+1
10133084529481 | 333*2^546934+1
100156363476569 | 555*2^721991+1
102765600059849 | 555*2^1040951+1
Xyzzy is offline   Reply With Quote
Old 2022-06-01, 23:59   #4
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

43328 Posts
Default

In windows, I would import the text file into excel as delimited text:

Excel >> Data >> From Text >> use appropriate delimited separator say "space" >> sort on the desired column, say the exponent >> Copy-All & Paste into a text file

If it was worth wasting time programming for, I would use javascript. Runs fine on windows.

Just my 2 cents.
a1call is offline   Reply With Quote
Old 2022-06-02, 08:13   #5
kruoli
 
kruoli's Avatar
 
"Oliver"
Sep 2017
Porta Westfalica, DE

1,087 Posts
Default

Pepi, would you be willingly to use WSL or MSYS under Windows? Then you can use the suggested Linux solutions.
kruoli is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export team standings ChristianV Programming 3 2018-12-27 22:13
Sorting on chinese remainder theorem alpertron Math 23 2017-12-15 16:46
Failed to Load GPU Sorting Engine (sort_engine_sm20.dll) GodyDeeps Msieve 5 2015-01-03 17:23
Card Sorting Probability Mini-Geek Math 13 2007-01-13 15:31
Sorting Files into 'chunks' of size X antiroach Programming 17 2004-03-01 01:15

All times are UTC. The time now is 23:32.


Fri Aug 12 23:32:33 UTC 2022 up 36 days, 18:19, 2 users, load averages: 1.39, 1.22, 1.16

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔